Last active
July 20, 2017 04:36
-
-
Save blubberdiblub/4c786db200e909f30fcf 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
#!/usr/bin/env python | |
import itertools | |
lines = ['one', 'two', 'three'] | |
it, it_look_ahead = itertools.tee(lines) | |
next(it_look_ahead) | |
for line in it: | |
print("this line: %s" % (line,)) | |
try: | |
next_line = next(it_look_ahead) | |
except StopIteration: | |
pass | |
else: | |
print("next line: %s" % (next_line,)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment