Dictionaries with invalid key?

Mr. Bigglesworth sitric at home.com
Thu Sep 9 11:20:54 EDT 1999


Strings are often used as keys, but other immutable objects work too (like
integers and tuples).  I'd recommend staying away from using integers as
keys, though, because it might confuse you later.  Don't forget that the
order in which keys appear in a dictionary is randomized; thus the integer
keys would not be in numerical order and might throw you off.

-Eric B.  (sitric at home.com)

"Gerhard W. Gruber" wrote:

> Usually a dictionary conists of a key and a value. I thought that keys
> are strings. Now I wrote some code that managed to create a key that is
> a number instead of a string. Is this a bug or is this ok?
> --
> bye,
>    Gerhard
> email: sparhawk at eunet.at
>        g.gruber at xsoft.co.at





More information about the Python-list mailing list