[Tutor] reading from stdin
nick at javacat.f2s.com
Tue Mar 1 23:26:29 CET 2005
On Tue, 2005-03-01 at 22:20 +0000, Max Noel wrote:
> I don't think you are. You're using readlines(), which means your
> program won't execute until ps terminates.
> 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
Aha, that makes sense. Thanks very much.
More information about the Tutor