lists and tuples
Gerrit Holl
gerrit at nl.linux.org
Sat Jun 28 09:39:06 EDT 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
impossible:
0 >>> d = {}
1 >>> l = []
2 >>> d[l] = "foo"
3 >>> d
{[]: 'foo'}
4 >>> l.append("bar")
5 >>> l
['bar']
6 >>> d
{['bar']: 'foo'}
What is the problem of doing this?
yours,
Gerrit.
--
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:
http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
http://www.sp.nl/
More information about the Python-list
mailing list