Created
March 2, 2014 03:22
-
-
Save ethanclevenger91/5933bbde2bdf024c2ea2 to your computer and use it in GitHub Desktop.
Get tokens separated by whitespace (Python)
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 readInts(file): | |
for line in file: | |
for element in line.split(): | |
yield element | |
elements = readInts(file) | |
for element in elements | |
#some code here | |
#next(elements) advanced iterator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment