Skip to content

Instantly share code, notes, and snippets.

@skylerberg
Created May 26, 2018 21:02
Show Gist options
  • Save skylerberg/895da7e71e2ea91c2f5e56fd0ad6125e to your computer and use it in GitHub Desktop.
Save skylerberg/895da7e71e2ea91c2f5e56fd0ad6125e to your computer and use it in GitHub Desktop.
Patch
def merge_patch(target, patch):
if isinstance(patch, dict):
if not isinstance(target, dict):
target = {}
for name, value in patch.iteritems():
if value is None:
if name in target:
del target[name]
else:
target[name] = merge_patch(target[name], value)
return target
else:
return patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment