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

David Abrahams David Abrahams" <david.abrahams@rcn.com
Thu, 11 Jul 2002 16:10:28 -0400


The real reason to be able to introspect is so that you can handle both
kinds.
Even if you're willing to destroy the data by examining it, if you know you
have a single-pass sequence, you might need to copy its elements into a
multi-pass sequence (e.g. file.lines()) in order to get your work done.


From: "Guido van Rossum" <guido@python.org>
> > I don't know if we need them, but I'm certainly finding that not having
> > some more information is difficult for me. If I need to make multiple
> > passes over the information in a generalized iterable object, the only
> > solution AFAICT is to unconditionally copy all the information into a
list
> > first.
>
> Or you could just document "this argument must support multiple
> independent iterators."