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

Greg Ewing greg@cosc.canterbury.ac.nz
Thu, 18 Jul 2002 11:32:22 +1200 (NZST)


Alex Martelli <aleax@aleax.it>:

> All files have seek and write, but not on all files do they work -- and
> the same goes for iteration.  I.e., it IS something of a mess

I've just had a thought. Maybe it would be less of a mess
if what we are calling "iterators" had been called "streams"
instead. Then the term "iterator" could have been reserved
for the special case of an object that provides stream
access to a random-access collection.

Then you could say that a file object is a stream object
that provides line-by-line access to an OS file. Other
stream objects can be constructed that give access to
the OS file in other units. That would all make sense
without seeming to imply any multi-pass ability.

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	   +--------------------------------------+