ddic = {'a': 10,'b': 23,'c': [0, 1, 2]}
n2 = ddic['c']
n2[-2] = 1000.
ddic
{'a': 10, 'b': 23, 'c': [0, 1000.0, 2]}
Why changing the list at which n2 is pointing, changes also the list of dict ddic, which is contained into the hash table that ddic defines?
It looks like that when you define a dict, the key-value pairs pops-in the global namespace and is not contained into the namespace defined by the hash-table structure.
Someone knows the detailed reason of this?
No comments:
Post a Comment