[Tutor] Why next vs. __next__ ?

Kent Johnson kent37 at tds.net
Tue Apr 22 04:15:30 CEST 2008

python at bdurham.com wrote:
> Is there a reason why generators have a special method named "next" vs.
> "__next__"?
> All other Python's special names have the double underscore
> prefix/suffix.
> http://docs.python.org/ref/specialnames.html

It's actually considered a mistake.

The original rationale is spelled out in PEP 234 - see the Resolved 
Issues section:

It is being renamed to __next__() in Python 3.0 and there will be a 
builtin next() method that calls it. Instead of iterator.next() you will 
call next(iterator).


More information about the Tutor mailing list