-
-
Save IndhumathyChelliah/b5f398a751e00f1a683c435a6f0758e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import ChainMap | |
d1={'a':1,'b':2} | |
d2={'c':3,'d':4} | |
chain1=ChainMap(d1,d2) | |
print (chain1)#Output:ChainMap({'a': 1, 'b': 2}, {'c': 3, 'd': 4}) | |
#parents method will return all maps in the current instance except first one. | |
print (chain1.parents)#Output:ChainMap({'c': 3, 'd': 4}) | |
d3={'e':5,'f':3} | |
chain2=ChainMap(d1,d2,d3) | |
print (chain2)#Output:ChainMap({'a': 1, 'b': 2}, {'c': 3, 'd': 4}, {'e': 5, 'f': 3}) | |
print (chain2.parents)#Output:ChainMap({'c': 3, 'd': 4}, {'e': 5, 'f': 3}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment