Skip to content

Instantly share code, notes, and snippets.

@alpden550
Created January 15, 2020 14:08
Show Gist options
  • Save alpden550/eac3fbc334dc5a5b4ad708434e4bcc48 to your computer and use it in GitHub Desktop.
Save alpden550/eac3fbc334dc5a5b4ad708434e4bcc48 to your computer and use it in GitHub Desktop.
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