Skip to content

Instantly share code, notes, and snippets.

@EricIO
Created January 19, 2017 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricIO/1df4793a36d0a22eddf3e2e044a4ffd7 to your computer and use it in GitHub Desktop.
Save EricIO/1df4793a36d0a22eddf3e2e044a4ffd7 to your computer and use it in GitHub Desktop.
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)
@zinob
Copy link

zinob commented Jan 19, 2017

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment