Skip to content

Instantly share code, notes, and snippets.

@stevedoyle
Created July 8, 2013 13:44
Show Gist options
  • Select an option

  • Save stevedoyle/5948882 to your computer and use it in GitHub Desktop.

Select an option

Save stevedoyle/5948882 to your computer and use it in GitHub Desktop.
Use fileinput to read input from files specified on the command line or stdin if no files specified. This allows something like: cat foo.txt | bar.py
import fileinput
for line in fileinput.input():
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment