def update_dict(target, source):
for k,v in source.items():<EOL><INDENT>if isinstance(v, dict) and k in target and isinstance(source[k], dict):<EOL><INDENT>update_dict(target[k], v)<EOL><DEDENT>else:<EOL><INDENT>target[k] = v<EOL><DEDENT><DEDENT>
Recursively merge values from a nested dictionary into another nested
dictionary.

For example:

>>> target = {
...     'thing': 123,
...     'thang': {
...         'a': 1,
...         'b': 2
...     }
... }
>>> source = {
...     'thang': {
...         'a': 666,
...         'c': 777
...     }
... }
>>> update_dict(target, source)
>>> target
{
    'thing': 123,
    'thang': {
        'a': 666,
        'b': 2,
        'c': 777
    }
}