reading from sys.stdin

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Apr 14 07:07:53 EDT 2007


In <1176538930.891355.230880 at n59g2000hsh.googlegroups.com>, 7stud wrote:

> Anyway, it seems everyone is saying that when you iterate over a file, the
> whole file is first read into memory.  Therefore iterating over sys.stdin
> is consistent: you have to type Ctrl+D to signal EOF before the iteration
> can start.  Is that about right?

Not the whole file is read but a block of it.  If you type in enough to
fill the buffer the iteration can start without an EOF on `sys.stdin`.

See the second example in <pan.2007.04.13.10.09.45.718859 at gmx.net> which
demonstrates that not the whole file is read at once by the iterator.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list