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

Aahz aahz at pythoncraft.com
Tue Mar 6 00:47:21 CET 2007


On Mon, Mar 05, 2007, Ka-Ping Yee wrote:
>
> Abstract
> ========
> 
> The iterator protocol in Python 2.x consists of two methods:
> ``__iter__()`` called on an iterable object to yield an iterator, and
> ``next()`` called on an iterator object to yield the next item in the
> sequence.  Using a ``for`` loop to iterate over an iterable object
> implicitly calls both of these methods.  This PEP proposes that the
> ``next`` method be renamed to ``__next__``, consistent with all the
> other protocols in Python in which a method is implicitly called as
> part of a language-level protocol, and that a built-in function named
> ``next`` be introduced to invoke ``__next__`` method, consistent with
> the manner in which other protocols are explicitly invoked.

+1 -- I was always against next() in the first place.  I'm +0 on
operator.next() relative to builtin next().
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"I disrespectfully agree."  --SJM


More information about the Python-3000 mailing list