Created
March 23, 2023 18:27
-
-
Save postpostscript/e4ff34df7f2abac366a74a5daa741179 to your computer and use it in GitHub Desktop.
deep_extend.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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