[Tutor] reading from stdin
Nick Lunt
nick at javacat.f2s.com
Tue Mar 1 23:23:12 CET 2005
On Tue, 2005-03-01 at 14:14 -0800, Sean Perry wrote:
>
> unless you want the output for some other reason, a more idiomatic way
> is:
>
> for line in sys.stdin.readlines():
> # handle the line
>
> I tend to use xreadlines() which does not read the entire input at once.
> For stdin this make sense, you have no idea how much data will be
> piped in.
Thanks Sean, I agree with you on both accounts there.
Cheers
Nick .
More information about the Tutor
mailing list