Dictionaries inside out

Ben Finney ben+python at benfinney.id.au
Fri Nov 26 18:29:15 EST 2010


Ben Finney <ben+python at benfinney.id.au> 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 is not to fix bugs. |
  `\                     It's absolutely not.” —Bill Gates, 1995-10-23 |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list