Revision 2384
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/dicts.py | ||
---|---|---|
40 | 40 |
if isinstance(value, list): value = tuple(value) |
41 | 41 |
elif isinstance(value, dict): value = util.NamedTuple(**value) |
42 | 42 |
return value |
43 |
|
|
44 |
def join(dict0, dict1): |
|
45 |
'''Joins dict0 (A->B mapping) to dict1 (B->C mapping) SQL-style. |
|
46 |
If a value in dict0 has no key in dict1, uses the value itself. |
|
47 |
''' |
|
48 |
new_dict = {} |
|
49 |
for out, in_ in dict0.iteritems(): |
|
50 |
new_dict[out] = dict1.get(in_, in_) # use in_ if no match found |
|
51 |
return new_dict |
Also available in: Unified diff
dicts.py: Added join()