|
|
|
|
|
by pmart123
2827 days ago
|
|
hmm. That is not what I would have expected. I would have thought it would update the value of the first map with the key "iMac", otherwise, add the key to the top level. The same would go for: >>> del inv['IMac'] deleting the key in the first mapping it appears. My guess is it is designed to ensure that updating a key will not update accidentally update a default mapping? This behavior could easily be prevented though by: >>> from types import MappingProxyType
>>> DEFAULTS = MappingProxyType(default_dict)
>>> ChainMap(overrides, DEFAULTS) |
|