Created
October 7, 2015 09:23
-
-
Save poros/ac4627304ad1d1cf6d78 to your computer and use it in GitHub Desktop.
Stop a generator midway
This file contains hidden or 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
lines = (for line in open("run/foo/access-log")) | |
# PYTHON 3 ONLY!!! | |
for i,line in enumerate(lines): | |
print line | |
if i == 10: lines.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment