[Python-Dev] NotHashableError? (Re: dict containment annoyance)

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Aug 14 04:26:14 CEST 2006

Guido van Rossum wrote:

> try:
>   hash(x)
> except TypeError:
>   # apparently x is not hashable
> then you're also swallowing any type errors in the computation of a
> legitimate hash function.

Maybe it would help if there were a specific exception,
such as NotHashableError, that hash functions were
expected to raise in this situation instead of a
generic TypeError.

For backwards compatibility it could be a subclass
of TypeError.


More information about the Python-Dev mailing list