[Python-Dev] Single- vs. Multi-pass iterability
Greg Ewing
greg@cosc.canterbury.ac.nz
Tue, 16 Jul 2002 10:48:28 +1200 (NZST)
Guido:
> Me:
> > 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.
>
> I don't think so. We should pick the most convenient chunking for the
> default iterator
But we're talking here about making the file object
*be* an iterator itself, not just have a "default
iterator". If that's to happen, all the
other ways of iterating over a file ought to be
implemented on top of the basic iteration facility
provided by the file object -- lest we get unfortunate
interactions between the different iteration methods
a la xreadlines(). To me, this implies that the file
object must iterate by bytes.
I'm not necessarily advocating this, just following
the idea to its logical conclusion. If the conclusion
is distasteful, maybe that's a sign that the idea
(i.e. making file objects into iterators)
isn't so good in the first place.
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg@cosc.canterbury.ac.nz +--------------------------------------+