[Python-3000] PEP: rename it.next() to it.__next__(), add a next() built-in
Brett Cannon
brett at python.org
Wed Mar 7 23:33:46 CET 2007
On 3/7/07, Guido van Rossum <guido at python.org> wrote:
> Since next() is equivalent to send(None) we don't really need the
> next() method do we?
>
Guess not, especially if we make send() default to sending None back.
-Brett
> On 3/7/07, Brett Cannon <brett at python.org> wrote:
> > On 3/7/07, Georg Brandl <g.brandl at gmx.net> wrote:
> > > Ka-Ping Yee schrieb:
> > > > On Wed, 7 Mar 2007, Georg Brandl wrote:
> > > >> Ka-Ping Yee schrieb:
> > > >> > On Tue, 6 Mar 2007, Guido van Rossum wrote:
> > > >> >> Having now read this entire thread I am going to accept Ping's PEP.
> > > >> >> Adding the sentinel argument to the next() builtin was what did it for
> > > >> >> me: it neatly solves the problem if having to catch that StopIteration
> > > >> >> in 99% of the cases.
> > > >> >
> > > >> > Okay, this is checked in as PEP 3114.
> > > >>
> > > >> Patch is at http://python.org/sf/1675363.
> > > >
> > > > Thanks for doing this work!
> > >
> > > I hope it helps getting a decision about the PEP.
> > >
> > > One thing that struck me while doing the next -> __next__ transition
> > > was the new asymmetry between generator methods; there is now send()
> > > and close(), but no next() anymore.
> > >
> >
> > Oooh, that's a good point. I guess that would mean generators should
> > keep their 'next' methods for API symmetry with 'send' and 'close';
> > calling next() just for when you are not sending something in would be
> > icky.
> >
> > But of course having two methods that do the exact same thing seems a
> > little icky as well. I was on the fence with this whole proposal, but
> > this makes me -0 on the rename and +0 on the new built-in.
> >
> > -Brett
> > _______________________________________________
> > Python-3000 mailing list
> > Python-3000 at python.org
> > http://mail.python.org/mailman/listinfo/python-3000
> > Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
> >
>
>
> --
> --Guido van Rossum (home page: http://www.python.org/~guido/)
>
More information about the Python-3000
mailing list