Skip to content

Instantly share code, notes, and snippets.

@saintsGrad15
Created July 23, 2020 19:05
Show Gist options
  • Select an option

  • Save saintsGrad15/2a9c65dc6249b123029869cf700e79ed to your computer and use it in GitHub Desktop.

Select an option

Save saintsGrad15/2a9c65dc6249b123029869cf700e79ed to your computer and use it in GitHub Desktop.
A tail-recursive function to return the value at a path within a dictionary.
def get_dict_path(dict_, path, default=None):
if len(path) < 1:
return dict_
return get_dict_path(dict_.get(path[0], default), path[1:], default)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment