python bijection

Francis Carr coldtortuga at
Fri Nov 27 19:12:36 CET 2009

I was really inspired by this discussion thread! :-)

After much tinkering, I think I have a simpler solution.  Just make
the inverse mapping accessible via an attribute, -AND- bind the
inverse of -THAT- mapping back to the original.  The result is a
python dict with NO NEW METHODS except this inverse-mapping
attribute.  I have posted it on as <a
href="">Recipe 576968:
Flipdict -- python dict that also maintains a one-to-one inverse

 -- F. Carr

More information about the Python-list mailing list