[Python-Dev] Single- vs. Multi-pass iterability

Guido van Rossum guido@python.org
Mon, 15 Jul 2002 10:15:28 -0400


> I think it's more complicated than that. If the file
> object were to become an object obeying the iterator
> protocol, its next() method should really return the
> next *byte* of the file. Then you'd still want methods
> like read(), readline() etc. for reading in larger
> chunks.

I don't think so.  We should pick the most convenient chunking for the
default iterator, and provide explicit ways to ask for other iterators
(like dict iterators).  Also, since "for line in file" already works,
there's a strong precedent for iterating by line by default.

--Guido van Rossum (home page: http://www.python.org/~guido/)