sys.stdin.readline()

Mike Maxwell maxwell at ldc.upenn.edu
Fri Sep 3 08:12:20 EDT 2004


Hallvard B Furuseth wrote:
> Mike Maxwell wrote:
>>When I invoke readline() in a for loop, why does it return a series of
>>one-char strings, rather than the full line?
>>
>>>>>for sL in sys.stdin.readline(): print sL
> 
> for sL in iter(sys.stdin.readline, ''): print sL,

You just forced me to look at the documentation for iter(), which I had 
previously avoided doing (on the excuse that it was confusing).  Thanks 
for the push!

	Mike Maxwell



More information about the Python-list mailing list