Why is dictionary.keys() a list and not a set?

Christoph Zwerschke cito at online.de
Fri Nov 25 10:02:25 CET 2005

bonono at gmail.com schrieb:

> And this, again from the doc(about mapping objects):
> A mapping object maps immutable values to arbitrary objects.
> Seems that is questionable too.
> a=(1,[])
> d={}
> d[a]=1
> again would give TypeError, list object are unhashable.

That's a good example showing that the term 'mutable' is not so 
well-defined as it may seem.

If you set b=[]; a=(1,b); should a be considered mutable (because you 
can change its value by changing b), or should it be considered 
immutable (because it is a tuple)?

-- Christoph

More information about the Python-list mailing list