Why is it that using the dict()
function does not create a copy with a nested dictionary as it does for a standard key:value pair dictionary?
Dictionary
A = {'key' : 'value'}
B = dict(A)
A['key'] = 10
print A, B
Output:
{'key': 10} {'key': 'value'}
Nested Dictionary:
A = {'key' : {'subkey' : 'value'}}
B = dict(A)
A['key']['subkey'] = 10
print A, B
Output:
{'key': {'subkey': 10}} {'key': {'subkey': 10}}