[Python-Dev] The iterator story

Clark C . Evans cce@clarkevans.com
Sat, 20 Jul 2002 12:21:01 -0400


On Fri, Jul 19, 2002 at 05:10:45PM -0400, Guido van Rossum wrote:
| > The __iter__-On-Iterators Issue:
| > 
| >     Some people have mentioned that the presence of an __iter__()
| >     method is a way of signifying that an object supports the
| >     iterator protocol.  It has been said that this is necessary
| >     because the presence of a "next()" method is not sufficiently
| >     distinguishing.
| 
| Not me.

As I remember the debate last year, Ping is expressing the 
concensus which was reached.  This issue was tied directly, although
not so articulately, to the namespace collision issue.  I remember
being concerned about next() not having leading and trailing __ but
my concerns were put to rest knowing that every iterator had to have
a __iter__ such that __iter__ returned self.   I wasn't on the list
for that long due to time constraints, but this linkage was there
at least for me.

| >     The iteration method is currently called "next()".
| > 
| >     Previous candidates for the name of this method were "next",
| >     "__next__", and "__call__".  After some previous debate,
| >     it was pronounced to be "next()".
| > 
| >     There are concerns that "next()" might collide with existing
| >     methods named "next()".  There is also a concern that "next()"
| >     is inconsistent because it is the only type-slot-method that
| >     does not have a __special__ name.
| > 
| >     The issue is, should it be called "next" or "__next__"?
| 
| That's a separate issue, and cleans up only a small wart that in
| practice hasn't hurt anybody AFAIK.

Today/tomorow I'll finish peicing together the survey so 
that it clearly articulates the issue (and I'll be sure to
note that you are against the idea).

Best,

Clark

-- 
Clark C. Evans                   Axista, Inc.
http://www.axista.com            800.926.5525
XCOLLA Collaborative Project Management Software