Skip to content

Instantly share code, notes, and snippets.

@mauicv
Created June 4, 2020 17:17
Show Gist options
  • Save mauicv/ce07bdb0c1eaba5937f10b6bdbe322c0 to your computer and use it in GitHub Desktop.
Save mauicv/ce07bdb0c1eaba5937f10b6bdbe322c0 to your computer and use it in GitHub Desktop.
[useful functions] #list_get #pairwise_iterator
from functools import reduce
import operator
from itertools import tee
def list_get(dictionary, list):
return reduce(operator.getitem, list, dictionary)
def pairwise(iterable):
a, b = tee(iterable)
next(b, None)
return zip(a, b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment