Reading from stdin
P at draigBrady.com
P at draigBrady.com
Thu Mar 11 06:03:01 EST 2004
Skip Montanaro wrote:
> Colin> However, I want the python script to print out the numbers as it
> Colin> gets them, since there could be hours/days between numbers - not
> Colin> a very efficient C program :). Actually, I would like to
> Colin> read-a-line/ print-a-line/ read-a-line/etc
>
> Colin> I have tried things like 'sys.stdin.read*' with no success.
>
> Have you tried this?
>
> import sys
> for line in sys.stdin:
> print line.strip()
That's block buffered. More details here:
http://www.pixelbeat.org/readline/python
Pádraig.
More information about the Python-list
mailing list