Generic singleton

Arnaud Delobelle arnodel at
Wed Mar 3 20:44:41 CET 2010

mk <mrkafk at> writes:
> hashable
> ..
>     All of Python’s immutable built-in objects are hashable, while no
> mutable containers (such as lists or dictionaries) are.
> Well ok, hashable they're not; but apparently at least dict and list
> have id()?

lists and dicts are not hashable, but their types are:

>>> hash(dict)
>>> hash(list)

So just use the type as the key to the dictionary you maintain in your
singleton.  But the question is what you use your singleton for.


More information about the Python-list mailing list