Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: lists and tuples (http://www.velocityreviews.com/forums/t318958-re-lists-and-tuples.html)

Gerrit Holl 06-28-2003 01:39 PM

Re: lists and tuples
 
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/



All times are GMT. The time now is 12:43 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.