Skip to content

Instantly share code, notes, and snippets.

@eidosam
Created September 15, 2022 15:21
Show Gist options
  • Save eidosam/45196bf3690ca329cb58664022ccbe7e to your computer and use it in GitHub Desktop.
Save eidosam/45196bf3690ca329cb58664022ccbe7e to your computer and use it in GitHub Desktop.
import copy
def merge_dict_deep(dest, src):
merged_dict = copy.deepcopy(dest)
for key in src:
if key not in dest:
merged_dict[key] = src[key]
elif isinstance(dest[key], dict) and isinstance(src[key], dict):
merged_dict[key] = merge_dict_deep(dest[key], src[key])
return merged_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment