[Tutor] reading from stdin

jfouhy at paradise.net.nz jfouhy at paradise.net.nz
Tue Mar 1 23:22:54 CET 2005

Quoting Sean Perry <shaleh at speakeasy.net>:

> for line in sys.stdin.readlines():
>  # handle the line
> I tend to use xreadlines() which does not read the entire input at once.

xreadlines() these days just does 'return self', I believe.  File objects are
their own iterators; you can just do:

for line in sys.stdin:
    # do stuff


More information about the Tutor mailing list