Skip to content

Instantly share code, notes, and snippets.

@ethanclevenger91
Created March 2, 2014 03:22
Show Gist options
  • Save ethanclevenger91/5933bbde2bdf024c2ea2 to your computer and use it in GitHub Desktop.
Save ethanclevenger91/5933bbde2bdf024c2ea2 to your computer and use it in GitHub Desktop.
Get tokens separated by whitespace (Python)
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