[Python-3000] PEP: rename it.next() to it.__next__(), add a next() built-in

"Martin v. Löwis" martin at v.loewis.de
Tue Mar 6 12:18:44 CET 2007


Greg Ewing schrieb:
> I'm -0.7. Classifying next() as an operator doesn't
> seem right -- what "operator" does it correspond to?
> 
> Unlike all the other functions in the operator
> module, there is no piece of syntax that corresponds
> directly to what next() would do. 

Not all of them. operator.attrgetter/itemgetter don't
directly correspond to a piece of syntax, either -
they return callables that correspond to the syntax.
operator.countOf relates to no syntax whatsoever.

operator.index is quite close to the proposed next()
method: __index__ doesn't directly correspond to
syntax, either, but is used as part of a "larger"
protocol (o[i], in this case, for an o that needs
numbers as indices).

operator.isNumberType,isMappingType,isSequenceType
don't correspond to syntax, either.

operator.truth again is similar to the proposed
next() builtin: the protocol it exposes is used
in several constructs (if, while), yet it doesn't
correspond to an operator (interestingly enough,
it is not an alias for the bool builtin type)

Regards,
Martin


More information about the Python-3000 mailing list