Reverse dictionnary

Julien Barbot barbot at shfj.cea.fr
Fri Nov 15 05:04:52 EST 2002


Hi,
Does "reverse dictionnary" exists in python ?
I would like to get a value with the key, and to get the key with the value
For example:
d1 = {1:"str1", 2:"str2" }

d1.getvalue(1) give me "str1"
and 
g1.getkey("str1") give me 1

With the result given as fast as normal dictionnaries.

If this does not exists, I will simply do two dictionnaries, one with
the integer as keys and the strings as values and the other one with
the strings as keys and the intergers as values.


Thanks for your help.
-- 
Julien Barbot



More information about the Python-list mailing list