Another approach is to subclass dict such that each time you add a key:value pair you also create an entry in a reverse dictionary. Then all you need do is lookup in the reverse dictionary.

If there are several keys with the same value, then create and extend a list of values in the reverse dictionary.

This will fail (as any other reverse dictionary approach will) if the values are not hashable

--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to