recursive_dict_update

sofia_redux.toolkit.utilities.func.recursive_dict_update(original, new)[source]

Recursively update a dictionary

Will update a nested dictionary with new values.

Parameters:
originaldict

The dictionary to update.

newdict

Dictionary containing new values.

Returns:
dict

The original dictionary updated with new values.

Examples

>>> from sofia_redux.toolkit.utilities.func import recursive_dict_update
>>> d1 = {'a': 1, 'b': {'c': 2, 'd': 3}}
>>> d2 = {'b': {'d': 4}}
>>> dnew = recursive_dict_update(d1, d2)
>>> print(dnew)
{'a': 1, 'b': {'c': 2, 'd': 4}}