[Tutor] Why next vs. __next__ ?

tiger12506 keridee at jayco.net
Wed Apr 23 05:23:10 CEST 2008

> It's actually considered a mistake.
> The original rationale is spelled out in PEP 234 - see the Resolved Issues 
> section:
> http://www.python.org/dev/peps/pep-0234/
> 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

It's not a method if it's global to the namespace. Or so I've been told. A 
built-in function.

> call next(iterator).
> http://www.python.org/dev/peps/pep-3114/

Which makes a lot more sense because then it follows the convention of:

int(MyObject) == MyObject.__int__()
str(MyObject) == MyObject.__str__()
float(MyObject) == MyObject.__float__()

etc. like all of the other special method names 

More information about the Tutor mailing list