Dictionaries inside out

Greg Lindstrom gslindstrom at gmail.com
Fri Nov 26 19:13:25 CET 2010


I am working on a project where I'm using dictionaries to hold the
translations to codes (i.e., {'1':'Cheddar','2':'Ice
Hockey','IL':'Thermostat Broken'}).  The bulk of the application requires me
to translate codes to their meaning, but it would be nice to be able to
translate a meaning back to the original code as well.  This seems to me
like it must be a common situation that has been addresses/solved by those
smarter than me.  Is there, dare I say, a design pattern for this problem?
Is there a better way of approaching it other than making a set of
dictionaries which "mirror" the originals?  FWIW, I have approximately 50
tables ranging from 2 entries to over 100.

Thanks,
--greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101126/6cfd50ec/attachment.html>


More information about the Python-list mailing list