Ben Finney writes:
> code_by_desc = dict(
> (desc, code) for (code, desc) in codes_to_messages.items())
Bah, I fumbled an edit. Try this::
code_by_desc = dict(
(desc, code) for (code, desc) in desc_by_code.items())
--
\“The reason we come up with new versions
(Replying to Greg, though his original message doesn't appear at Gmane.)
> Greg Lindstrom 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
On 11/26/2010 1:13 PM, Greg Lindstrom wrote:
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 ni
Found in Dive in Python 3 :
>>> a_dict = {'a': 1, 'b': 2, 'c': 3}
>>> {value:key for key, value in a_dict.items()}
{1: 'a', 2: 'b', 3: 'c'}
2010/11/26 Burton Samograd
> Greg Lindstrom writes:
>
> > I am working on a project where I'm using dictionaries to hold the
> > translations to codes (i
Greg Lindstrom 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 abl
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 th