Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import collections
- def merge_dict(d1, d2):
- for k,v2 in d2.items():
- v1 = d1.get(k) # returns None if v1 has no value for this key
- if ( isinstance(v1, collections.Mapping) and
- isinstance(v2, collections.Mapping) ):
- merge_dict(v1, v2)
- else:
- d1[k] = v2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement