Created
October 4, 2015 16:16
-
-
Save poros/6d0fdd5e98ad768b36e7 to your computer and use it in GitHub Desktop.
Overriding dictionaries
This file contains hidden or 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
d = defaults.copy() | |
d.update(os.environ) | |
d.update(command_line_arguments) | |
# PYTHON3 ONLY!!! | |
from collections import ChainMap | |
d = ChainMap(command_line_arguments, os.environ, defaults) | |
# it's view, not a real dictionary. if you want something equivalent to a new one | |
d = ChainMap({}, command_line_arguments, os.environ, defaults) | |
# writes are done on the first map in the list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment