Created
September 15, 2022 15:21
-
-
Save eidosam/45196bf3690ca329cb58664022ccbe7e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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