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

Guido van Rossum guido@python.org
Wed, 17 Jul 2002 16:04:12 -0400


> But i think this is more than a minor problem.  This is a
> namespace collision problem, and that's significant.  Naming
> the method "next" means that any object with a "next" method
> cannot be adapted to support the iterator protocol.  Unfortunately
> "next" is a pretty common word and it's quite possible that such
> a method name is already in use.

Can you explain this?  Last time I checked CVS, PEP 246 wasn't
implemented yet, so I don't think you mean "adapted" in that sense.
Generally speaking, iterator implementations aren't created by making
changes to an existing class -- they're created by creating new a
class.  The only change to *existing* classes needed is the addition
of an __iter__ method to the underlying container object.  So I'm not
sure what you mean.

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