Why are types not hashable?

Raymond Hettinger python at rcn.com
Tue May 28 16:51:41 EDT 2002


I think you have a typo.  Perhaps you meant:

for t in alltypes: typestrings[eval('types.' + t)] = t


Raymond Hettinger




"VanL" <vlindberg at verio.net> wrote in message
news:3CF3E7A4.9010103 at verio.net...
>
> 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