Skip to content

Instantly share code, notes, and snippets.

@johnberroa
Created September 10, 2019 14:37
Show Gist options
  • Save johnberroa/8e6d383b5f8d449010fff6a2f294af90 to your computer and use it in GitHub Desktop.
Save johnberroa/8e6d383b5f8d449010fff6a2f294af90 to your computer and use it in GitHub Desktop.
Dive into a dictionary given a key path separated by "/"
def dive_into_dict(path, dic):
path = path.split("/")
key = path[0]
result = dic[key]
if isinstance(result, dict):
result = dive_into_dict("/".join(path[1:]), result)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment