Last active
December 19, 2015 03:08
-
-
Save gonz/5887673 to your computer and use it in GitHub Desktop.
get_dot(adict, 'key1.key2')
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_dot(self, d, dotkey): | |
"""Get value from a dict with dot notation keys""" | |
try: | |
value = d | |
for key in dotkey.split('.'): | |
value = value.get(key) | |
return value | |
except AttributeError: | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment