I usually do this in Perl:
whatever.pl
while(<>) { #do whatever; }
then cat foo.txt | whatever.pl
cat foo.txt | whatever.pl
Now, I
Something like this:
import sys for line in sys.stdin: # whatever