[Tutor] Why next vs. __next__ ?
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
> 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
> call next(iterator).
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