Last active
November 11, 2016 17:37
-
-
Save jzbruno/8d397b33a0ad97f973d76cf14d7e370c to your computer and use it in GitHub Desktop.
Get a nested value from a dictionary using a period separated list of keys.
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
def get_nested_value(originalDict, path): | |
keys = path.split('.') | |
val = originalDict | |
for key in keys: | |
val = val.get(key) | |
return val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment