Created
November 20, 2015 13:10
-
-
Save Cloudo/e7eecfb9c630c6d5b96d to your computer and use it in GitHub Desktop.
access deep nested value from python dict
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
| 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