Thanks again. This is very helpful.
--
http://mail.python.org/mailman/listinfo/python-list
Super simple:
dict3 = {}
for k1 in dict1.keys():
for k2 in dict2.keys():
if dict1.get(k1) == dict2[k2]:
dict3[k1] = k2
works in all cases and can be simplified to an iterated dictionary in
python 2.4
--
http://mail.python.org/mailman/listinfo/python-list
ProvoWallis <[EMAIL PROTECTED]> wrote:
...
> The keys in the new dictionary would be the keys from the old
> dictionary one (dict1) and the values in the new dictionary would be
> the keys from the old dictionary two (dict2). The keys would be joined
> by matching the values from dict1 and dict2
ProvoWallis wrote:
> Thanks so much. I never would have been able to figure this out on my
> own.
>
> def dictionary_join(one, two):
>
> dict2x = dict( ((dict2[k], k) for k in dict2.iterkeys()))
> dict3 = dict(((k, dict2x[v]) for k,v in dict1.iteritems()))
> print dict3
>
> dict1 =
Thanks so much. I never would have been able to figure this out on my
own.
def dictionary_join(one, two):
dict2x = dict( ((dict2[k], k) for k in dict2.iterkeys()))
dict3 = dict(((k, dict2x[v]) for k,v in dict1.iteritems()))
print dict3
dict1 = {1:'bbb', 2:'aaa', 3:'ccc'}
dict2 =
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?
>
> The keys in the new dictionary wo
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 usu
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?
The keys in the new dictionary would be the keys from the old
di