Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: lists and tuples

Reply
Thread Tools

Re: lists and tuples

 
 
Gerrit Holl
Guest
Posts: n/a
 
      06-28-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/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dictionaries with tuples or tuples of tuples Jon Reyes Python 18 02-19-2013 03:56 AM
Passing tuples of tuples to sqlite xera121 Python 8 09-30-2009 05:45 AM
tuples within tuples korovev76@gmail.com Python 12 10-27-2007 08:16 PM
Re: Lists of lists and tuples, and finding things within them Daniel Nogradi Python 3 11-10-2006 07:57 AM
Different tuples to one container? (One type of a pointer to point to different kinds of tuples?) fff_afafaf@yahoo.com C++ 5 10-05-2006 11:17 PM



Advertisments