Skip to content

Instantly share code, notes, and snippets.

@gonz
Last active December 19, 2015 03:08
Show Gist options
  • Save gonz/5887673 to your computer and use it in GitHub Desktop.
Save gonz/5887673 to your computer and use it in GitHub Desktop.
get_dot(adict, 'key1.key2')
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