newbie question about dictionnary ?

Michael Peuser mpeuser at web.de
Fri Sep 5 04:24:41 EDT 2003


"Sophie Alléon" <alleon at club-internet.fr> schrieb im Newsbeitrag
news:3f582f90$0$20952$7a628cd7 at news.club-internet.fr...


> for doing this I thought the dictionary was excellent but the key is a
> string while I want it
> to be the 2 points forming the edge ? How to do it ?
>

Luckily you are wrong! Keys can be numbers, strings, AND tuples of immutable
data!!!

Example:

a="first"
b=2
x={}
x[(a,b)]="hi"
print x

However it will not work when assigning objects or lists to a or b.

So you can use it when you store your objects in a list and refer to them by
indexes. This is old fashioned stuff but may be really efficient.

Kindly
Michael P







More information about the Python-list mailing list