I have the following Python 2.7.16 dictionary with default values:
settings = {
'alpha': {
'Add': [],
'Delete': [],
'Patch': {
'Software': False,
'Hardware': False
}
},
'beta': {
'Flash': [],
'Definitions': {
'Occur': False,
'Define': False,
'Disable': False,
'Enable': False
}
},
'gamma': {
'Allow': {},
'Block': {}
}
}
I want to update the settings
dictionary with values from a new dictionary, as defined:
new_settings = {
'alpha': {
'Delete': ['model', 'structure'],
'Patch': {
'Software': True
}
},
'beta': {
'Definitions': {
'Define': True,
'Disable': True
}
},
'gamma': {
'Allow': {
'Update': True
}
}
}
The end-result would be the following merged dictionary:
settings = {
'alpha': {
'Add': [],
'Delete': ['model', 'structure'],
'Patch': {
'Software': True,
'Hardware': False
}
},
'beta': {
'Flash': [],
'Definitions': {
'Occur': False,
'Define': True,
'Disable': True,
'Enable': False
}
},
'gamma': {
'Allow': {
'Update': True
},
'Block': {}
}
}
I tried:
configuration = settings.copy()
configuration.update(new_settings)
But that would result of some of the keys being removed from setting
dictionary.
Thank you.