Re: Coroutines: unexpected behaviour

2010-06-16 Thread Jérôme Mainka
On 16 juin, 20:11, Carl Banks wrote: > I suggest, if you intend to use this kind of thing in real code (and I > would not recommend that) that you get in a habit of explicitly > closing the generator after the last send(), even when you don't think > you have to. Very clear explanation. Thanks f

Re: Coroutines: unexpected behaviour

2010-06-16 Thread Carl Banks
On Jun 16, 5:03 am, Jérôme Mainka wrote: > Hello, > > I try to experiment with coroutines and I don't understand why this > snippet doesn't work as expected... In python 2.5 and python 2.6 I get > the following output: > > 0 > Exception exceptions.TypeError: "'NoneType' object is not callable" in

Re: Coroutines: unexpected behaviour

2010-06-16 Thread Thomas Jollans
On 06/16/2010 06:35 PM, Steven D'Aprano wrote: > On Wed, 16 Jun 2010 05:03:13 -0700, Jérôme Mainka wrote: > >> Hello, >> >> I try to experiment with coroutines and I don't understand why this >> snippet doesn't work as expected... In python 2.5 and python 2.6 I get >> the following output: >> >> 0

Re: Coroutines: unexpected behaviour

2010-06-16 Thread Jérôme Mainka
On Jun 16, 6:35 pm, Steven D'Aprano wrote: > How bizarre is that? Sure... > I have to say that your code is horribly opaque and unclear to me. Welcome to the coroutines world :-) This is mainly a pipeline where each function suspends execution waiting for data (yield), and feeding other functi

Re: Coroutines: unexpected behaviour

2010-06-16 Thread Steven D'Aprano
On Wed, 16 Jun 2010 05:03:13 -0700, Jérôme Mainka wrote: > Hello, > > I try to experiment with coroutines and I don't understand why this > snippet doesn't work as expected... In python 2.5 and python 2.6 I get > the following output: > > 0 > Exception exceptions.TypeError: "'NoneType' object is

Re: Coroutines: unexpected behaviour

2010-06-16 Thread Thomas Jollans
On 06/16/2010 02:03 PM, Jérôme Mainka wrote: > Hello, > > I try to experiment with coroutines and I don't understand why this > snippet doesn't work as expected... In python 2.5 and python 2.6 I get > the following output: > > 0 > Exception exceptions.TypeError: "'NoneType' object is not callable