What does hashable mean?

Python data types and strings · Experienced

Model answer

A hashable object has a hash value that never changes during its lifetime and can be compared for equality. Only hashable objects can be dictionary keys or set members. Immutable built-ins are hashable. Lists and dicts are not. A custom class that defines __eq__ needs a matching __hash__ to be usable in sets.

Learn this topic

Variables, Numbers, Text and input() in Python in the course Python for Beginners: Learn to Code with Real Projects.

Sign in to add your own answer.

More questions