join dictionaries using keys from one & values

Erik Max Francis max at alcyone.com
Mon Dec 5 23:30:27 EST 2005


ProvoWallis wrote:

> I'm still learning python so this might be a crazy question but I
> thought I would ask anyway. Can anyone tell me if it is possible to
> join two dictionaries together to create a new dictionary using the
> keys from the old dictionaries?

There is no builtin method.  The usual way is to just wrap a class 
around two dictionaries, one for mapping keys to values and the other 
for mapping values back to keys.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Yes I'm / Learning from falling / Hard lessons
   -- Lamya



More information about the Python-list mailing list