Created
June 4, 2020 17:17
-
-
Save mauicv/ce07bdb0c1eaba5937f10b6bdbe322c0 to your computer and use it in GitHub Desktop.
[useful functions] #list_get #pairwise_iterator
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 | |
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