def update ( dct , dct_merge ) : for key , value in dct_merge . items ( ) : if key in dct and isinstance ( dct [ key ] , dict ) : dct [ key ] = update ( dct [ key ] , value ) else : dct [ key ] = value return dct
python dict merge deep
Recursively merge dicts .
def update(dct, dct_merge):
    """Recursively merge dicts."""
    for key, value in dct_merge.items():
        if key in dct and isinstance(dct[key], dict):
            dct[key] = update(dct[key], value)
        else:
            dct[key] = value
    return dct