Re: Generators and their next() and send() methods

2008-11-18 Thread Aaron Brady
On Nov 18, 5:20 pm, Thomas Mlynarczyk <[EMAIL PROTECTED]> wrote: > Aaron Brady schrieb: > > > And, if you don't intend to use 'myway' on 'listiterator's and such, > > 'send( None )' is equivalent to 'next( )'. > > I didn't know that. But doesn't that impose a restriction somehow? It > makes it impo

Re: Generators and their next() and send() methods

2008-11-18 Thread Thomas Mlynarczyk
Aaron Brady schrieb: And, if you don't intend to use 'myway' on 'listiterator's and such, 'send( None )' is equivalent to 'next( )'. I didn't know that. But doesn't that impose a restriction somehow? It makes it impossible to send a None to a generator. Greetings, Thomas -- Ce n'est pas pa

Re: Generators and their next() and send() methods

2008-11-18 Thread Thomas Mlynarczyk
alex23 schrieb: http://www.python.org/dev/peps/pep-0342/ That links to the original proposal to extend the generator behaviour After some searching, I found this as a remark in parentheses: "Introducing a new method instead of overloading next() minimizes overhead for simple next() calls."

Re: Generators and their next() and send() methods

2008-11-16 Thread Aaron Brady
On Nov 16, 3:36 pm, Thomas Mlynarczyk <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle schrieb: > > > If you want to simply 'set' the generator (by which I take you mean > > 'change its state') without without iterating it one step, then what you > > need is a class with an __iter__() method.  Then yo

Re: Generators and their next() and send() methods

2008-11-16 Thread alex23
On Nov 17, 7:36 am, Thomas Mlynarczyk <[EMAIL PROTECTED]> wrote: > Still, I would like to know why it was decided to > introduce a send() method instead of allowing an argument for next(). Hey Thomas, A great place to gain insight into the reasoning behind changes to Python is the PEPs: http://w

Re: Generators and their next() and send() methods

2008-11-16 Thread Thomas Mlynarczyk
Arnaud Delobelle schrieb: If you want to simply 'set' the generator (by which I take you mean 'change its state') without without iterating it one step, then what you need is a class with an __iter__() method. Then you can change the state of the object between calls to next(). E.g. class M

Re: Generators and their next() and send() methods

2008-11-15 Thread Arnaud Delobelle
Thomas Mlynarczyk <[EMAIL PROTECTED]> writes: > Hello, > > I was playing around a bit with generators using next() and > send(). And I was wondering why an extra send() method was introduced > instead of simply allowing an argument for next(). > > Also, I find it a bit counter-intuitive that send(