Skip to content

Instantly share code, notes, and snippets.

Created July 9, 2020 20:49
What would you like to do?
from collections import ChainMap
print (d3)#Output:ChainMap({'a': 1, 'b': 2, 'c': 3}, {'d': 4, 'e': 5})
#Adding value in first mapping.It will update values only in first mapping.
print (d3)#Output:ChainMap({'a': 1, 'b': 2, 'c': 3, 'e': 99}, {'d': 4, 'e': 5})
#deleting value.It will delete values only from first mapping.Since 'd' is not in first mapping,it raises key Error
#del d3['d']
#Output:KeyError: "Key not found in the first mapping: 'd'"
#Accessing values,it will lookup the full chain.
print (d3['d'])#Output:4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment