Skip to content

Instantly share code, notes, and snippets.

@sergiors
Last active August 23, 2018 14:11
Show Gist options
  • Save sergiors/de0dbdb76601020e38f83c47eb63635c to your computer and use it in GitHub Desktop.
Save sergiors/de0dbdb76601020e38f83c47eb63635c to your computer and use it in GitHub Desktop.
def path(dct: dict, paths: list):
k = paths[0]
v = dct.get(k, None)
return v if type(v) is not dict else path(v, paths[1:])
# or
def path(dct: dict, paths: list):
k = paths[0]
v = dct.get(k, None)
if type(v) is not dict:
return v
return path(v, paths[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment