Greg Lindstrom <gslindst...@gmail.com> writes:

> 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.

Looks like there might be some solutions here:

http://stackoverflow.com/questions/483666/python-reverse-inverse-a-mapping

--
Burton Samograd

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to