Given a one-to-one dictionary (=bijection) generated à la
for key, value in someGenerator:
myDict[key] = value
an inverse lookup dictionary can be trivially created by adding
invDict[value] = key
to the for
loop. But is this a Pythonic way? Should I instead write a class Bijection(dict)
which manages this inverted dictionary in addition and provides a second lookup function? Or does such a structure (or a similar one) already exist?