Coding and Decoding in Python

John Gordon gordon at panix.com
Thu Mar 17 12:07:51 EDT 2011


In <7546e476-d10f-46e5-8b20-5d9b423456e6 at r6g2000vbo.googlegroups.com> Wanderer <wanderer at dialup4less.com> writes:

> I guess two keys having the same value is why dictionaries don't
> return keys for values, but this is a code. Each value has a unique
> meaning to both sender and receiver. The text part is for making the
> program understandable and printing understandable error messages.

I see.  You're storing integer equivalents for the labels themselves,
not the actual data associated with the labels.

Then Mel's solution is a good one -- construct a second dict which
has the keys and values swapped.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon at panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"




More information about the Python-list mailing list