lists and tuples

Gerrit Holl gerrit at
Sat Jun 28 15:39:06 CEST 2003

John Hunter wrote:
>     Gerrit> I don't understand. I really don't understand.
> For me, the most important distinction is that because lists are
> mutable, they cannot be used as keys in a dictionary.

This is probably a basic question, but I can't see why mutable
objects can't be used as dictionairy keys. Why would this be

  0 >>> d = {}
  1 >>> l = []
  2 >>> d[l] = "foo"
  3 >>> d
{[]: 'foo'}
  4 >>> l.append("bar")
  5 >>> l
  6 >>> d
{['bar']: 'foo'}

What is the problem of doing this?


59. If any man, without the knowledge of the owner of a garden, fell a
tree in a garden he shall pay half a mina in money.
        -- 1780 BC, Hammurabi, Code of Law
Asperger Syndroom - een persoonlijke benadering:
Het zijn tijden om je zelf met politiek te bemoeien:

More information about the Python-list mailing list