[Python-3000] PEP: rename it.next() to it.__next__(), add a next() built-in
barry at python.org
Mon Mar 5 19:44:12 CET 2007
-----BEGIN PGP SIGNED MESSAGE-----
On Mar 5, 2007, at 1:36 PM, Martin v. Löwis wrote:
> -1. I dislike the introduction of more builtins unless they have a
> generality (i.e. are likely to be needed in many programs). For this
> one, I think the normal usage of __next__ will be with a for loop, so
> I don't think one would often need an explicit next() invocation.
I have had occasional need to call .next() explicitly. IIRC the code
in question was handed an iterator but only needed the first object
out of the iterator. It would be really ugly to have to use __next__
() or force a once-through for loop.
OTOH, making iterators callable as equivalent to .next() as I think
Raymond suggested sounds about perfect. You get __next__(), plus
explicit iteration with no additional built in necessary.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
-----END PGP SIGNATURE-----
More information about the Python-3000