Skip to content

Instantly share code, notes, and snippets.

@postpostscript
Created March 23, 2023 18:27
Show Gist options
  • Save postpostscript/e4ff34df7f2abac366a74a5daa741179 to your computer and use it in GitHub Desktop.
Save postpostscript/e4ff34df7f2abac366a74a5daa741179 to your computer and use it in GitHub Desktop.
deep_extend.py
def deep_extend(base, arg):
if not (isinstance(base, dict) and isinstance(arg, dict)):
return arg
return dict([
*base.items(),
*map(
lambda item: (
item[0],
deep_extend(base.get(item[0], None), item[1])),
arg.items()),
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment