Skip to content

Instantly share code, notes, and snippets.

@Cloudo
Created November 20, 2015 13:10
Show Gist options
  • Select an option

  • Save Cloudo/e7eecfb9c630c6d5b96d to your computer and use it in GitHub Desktop.

Select an option

Save Cloudo/e7eecfb9c630c6d5b96d to your computer and use it in GitHub Desktop.
access deep nested value from python dict
import re
def get_path(dct, path):
for i, p in re.findall(r'(\d+)|(\w+)', path):
dct = dct[p or int(i)]
return dct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment