hashable

Describes a Python object that has a hash value that never changes during its lifetime and can be compared for equality, so it can be a dict key or set member.

In more detail

Immutable built-ins such as int, str and tuples of hashable values are hashable. Mutable containers such as list, dict and set are unhashable, and trying to use one as a key raises TypeError. A class that defines __eq__ without __hash__ becomes unhashable by default.

Related terms

Taught in

References

Certification courses