Created
January 15, 2020 14:08
-
-
Save alpden550/eac3fbc334dc5a5b4ad708434e4bcc48 to your computer and use it in GitHub Desktop.
This file contains 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
from functools import reduce | |
from operator import getitem | |
def walk(dictionary, keys): | |
return reduce(lambda d, key: d.get(key) if d else None, keys, dictionary) | |
def another_walk(dictionary, path): | |
return reduce(getitem, path, dictionary) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment