Quoting Max Noel <[EMAIL PROTECTED]>:
>       UNIX philosophy is to have programs start acting as soon as possible 
> -- in that case, as soon as the first line is available. You should be 
> reading sys.stdin as an iterator (same thing you'd do for a file):
> 
> import sys
> for line in sys.stdin:
>       # do stuff with that line of input

Is this sufficient?  I tried to write a test program to get that behaviour..

----- produce.py -----
#!/usr/bin/python

import time
for i in xrange(10):
 time.sleep(1)
 print i

----- read.py -----
#!/usr/bin/python

import sys
for line in sys.stdin:
 print line.strip()

--------------------

If I do:

$ ./produce.py | ./read.py

I get nothing for ten seconds, then I get the numbers 0 through 9, one per line.

What am I missing?

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to