list vs tuple for a dict key- why aren't both hashable?

Syeberman syeberman at hotmail.com
Tue Nov 10 12:44:55 EST 2009


On Nov 8, 3:42 pm, Mick Krippendorf <mad.m... at gmx.de> wrote:
> Wells wrote:
> > I'm not quite understanding why a tuple is hashable but a list is not.
>
> The short answer has already been given.
>
The short answer isn't entirely correct, however.  Tuples are only
hashable so long as their elements are all hashable.  The
documentation, though, doesn't properly describe this:
  http://docs.python.org/glossary.html#term-hashable
  "All of Python’s immutable built-in objects are hashable"



More information about the Python-list mailing list