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

Guido van Rossum guido at python.org
Mon Mar 5 19:48:50 CET 2007


On 3/5/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:

As an alternative, I propose that object grows a .next() method, which calls next by default.

This would seem slated to confuse users; they will attempt to implement next() instead of next(). Or people would attempt to override these differently. If the builtin next() bites the dust, I would rather learn to live with calling next() directly, just as for certain occasions one resorts to call import().

On 3/5/07, python at rcn.com <python at rcn.com> wrote:

Can I suggest that next() and next() be dropped entirely and that iterators just be made callable.

This sounds attractive, except that I fear that the optimizations we've implemented for calling tp_next (especially for built-in iterators like list or dict iterators). Since tp_call must be usable in other contexts, and has much more optional features, it will be hard to carry these optimizations over.

It would also invalidate classes that serve as their own iterator (like files) and already implement call() for sa different purpose.

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-3000 mailing list