Dictionaries with invalid key?

Greg Ewing greg.ewing at compaq.com
Mon Sep 6 17:53:59 EDT 1999


Oleg Broytmann wrote:
> 
>    Dictionary's key may be any immutable object. Tuple, for example.

Some mutable objects can be used as keys, too -- e.g. a class instance.
If the class defines __hash__ and __cmp__ methods, they will be used
to determine whether two keys match; otherwise, pointer comparison is
used.

Greg




More information about the Python-list mailing list