Why are types not hashable?

VanL vlindberg at verio.net
Tue May 28 16:25:08 EDT 2002


What prevents this from working:

 >>> import types
 >>> alltypes = [t for t in types.__dict__.keys() if t[:2] 
!= '__']
 >>> typestrings ={}
 >>> for t in alltypes: typestrings[eval('types.' + t): t]
...
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: unhashable type


Why is <type 'dict'> not hashable?  Surely its not mutable?

Thanks,

Van




More information about the Python-list mailing list