[Tutor] reading from stdin

Nick Lunt nick at javacat.f2s.com
Tue Mar 1 23:28:02 CET 2005


On Wed, 2005-03-02 at 11:22 +1300, jfouhy at paradise.net.nz wrote:
> 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
> 

Same as Max Noel said, must be a good idea ;)

Thankyou
Nick .



More information about the Tutor mailing list