[Python-3000] PEP: rename it.next() to it.__next__(), add a next() built-in
Josiah Carlson
jcarlson at uci.edu
Tue Mar 6 00:01:33 CET 2007
"Guido van Rossum" <guido at python.org> wrote:
> On 3/5/07, Josiah Carlson <jcarlson at uci.edu> wrote:
> > because [...] 2) it renames a protocol method, making it
> > potentially difficult and/or buggy to write forward or backward
> > compatible code, [...]
>
> Did you see my slides and/or video of my talk about Py3k yet? This
> change can be carried out automatically.
I read the slides.
However, I have written methods named 'next' which have *nothing* to do
with the iterator protocol. I probably should have written them as
something like 'get_next' so as not to confuse later readers, but the
lack of an __iter__, specific documentation about what .next() means,
and the context in which it was written, read much better with .next()
than .get_next(), or any one of the handful of other names (and
alternate naming semantics) I considered at the time.
Barry Warsaw <barry at python.org> wrote:
> Perhaps, but I think there's a valid use case for calling "next"
> explicitly, and I would really hate for that to be spelled
> "it.__next__()".
I agree, which is one of the reasons why I personally prefer the
status-quo: it.next() . It works. Has always worked. And the 2to3
translator won't get confused by non-iterator-based .next() methods
(which I'm not claiming are common, merely that they exist).
- Josiah
More information about the Python-3000
mailing list