Last active
August 23, 2018 14:11
-
-
Save sergiors/de0dbdb76601020e38f83c47eb63635c to your computer and use it in GitHub Desktop.
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
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