Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. import collections
  2.  
  3. def merge_dict(d1, d2):
  4. for k,v2 in d2.items():
  5. v1 = d1.get(k) # returns None if v1 has no value for this key
  6. if ( isinstance(v1, collections.Mapping) and
  7. isinstance(v2, collections.Mapping) ):
  8. merge_dict(v1, v2)
  9. else:
  10. d1[k] = v2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement