Created
December 16, 2015 13:03
-
-
Save robcowie/5267811487c4dd981f2d 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
import operator as op | |
# g = nested_getter(1, 1, 1) | |
# g((0, (0, (0, 1)))) -> 1 | |
def nested_getter(*args): | |
def getter(seq): | |
for func in (op.itemgetter(a) for a in args): | |
seq = func(seq) | |
return seq | |
return getter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment