Skip to content

Instantly share code, notes, and snippets.

@liweicheng00
Created July 14, 2022 03:24
Show Gist options
  • Save liweicheng00/ea0cd5e789aa496df676b65417505ef9 to your computer and use it in GitHub Desktop.
Save liweicheng00/ea0cd5e789aa496df676b65417505ef9 to your computer and use it in GitHub Desktop.
Update nest dictionary fro Python
def update(d: dict, u) -> dict:
for k, v in u.items():
if isinstance(v, collections.abc.Mapping):
d[k] = update(d.get(k, {}), v)
else:
d[k] = v
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment