dictionary with complex keys

Peter Schneider-Kamp petersc at stud.ntnu.no
Tue Jun 6 15:55:28 EDT 2000


Stefan Seefeld wrote:
> 
> I'm trying to create a dictionary with the keys being lists.
> How can I do that ? The docs say that only simple types are
> possible as keys. Is there a way to achieve what I want ? May
> be some special operator I need to define...

Your problem is that keys have to be immutable to be used
in dictionaries. You can use tuple(somelist) as the key
though in most cases because it is immutable.

do-changing-keys-make-sense-?-ly y'rs Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter at schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de




More information about the Python-list mailing list