reverse mapping of dictionary with Python

Viewed 15590

Possible Duplicate:
Inverse dictionary lookup - Python

If I have a dictionary named ref as follows

ref = {}
ref["abc"] = "def"

I can get "def" from "abc"

def mapper(from):
    return ref[from]

But, how can I get from "def" to "abc"?

def revmapper(to):
    ??????
3 Answers
Related