Skip to content

Instantly share code, notes, and snippets.

@skamithi
Created May 7, 2014 01:05
Show Gist options
  • Save skamithi/6dd83f2c6f73cf0a2130 to your computer and use it in GitHub Desktop.
Save skamithi/6dd83f2c6f73cf0a2130 to your computer and use it in GitHub Desktop.
Python Merge simple dictionaries
def dict_merge(list1, list2):
""" Trick is to use the .__dict__ keyword. This puts all the attrs associated with
this library's instance are part of the mergin algorithm
_keys = list2.keys()
try _key in keys:
try:
list1[key].__dict__.update(list2[__key].__dict__)
except:
list[_key] = list2[_key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment