Iteration on file reading

Andrew Dalke adalke at mindspring.com
Thu Oct 2 19:22:54 EDT 2003


Paul Watson
>     for line in sys.stdin:
>
> Does this statement cause all of stdin to be read before the loop begins?

No.  It will read a block of text at a time and break that block
into lines.  This gives great performance and is scalable to
large files (so long as you can can afford to keep that extra
block around).  However, it's lousy for interactive work.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list