Created
January 19, 2017 11:55
-
-
Save EricIO/1df4793a36d0a22eddf3e2e044a4ffd7 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
def split_iter(iter, index): | |
for x in iter: | |
yeild x[index] | |
def split_tuple(iter): | |
return split_iter(0), split_iter(1) | |
foo = [(1,2),(3,4),(5,6)] | |
a,b = split_tuple(foo) | |
for x in a: | |
print(x) | |
for x in b: | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the end i went for:
a,b=itertools.tee(classify_files())
X = (i[0] for i in a)
Y = (i[1] for i in b)