Re: What is executed when in a generator

2005-10-09 Thread Michael
[ I've got no idea of your skill level, but since you say you feel a bit lost I'll take baby steps here. Apologies if it's too low or high :-) I'm also taking baby steps because less people understand generators than they might. After all, most new programmers often want something like gene

Re: What is executed when in a generator

2005-10-04 Thread Jerzy Karczmarczuk
Thank you all for some precisions about yield and generators. But I would like to underline that I am *not* a complete newbie, and I understand this stuff in general. I read the yield.html material quite a time ago. But thank you for the PEP, I should have scanned it more carefully. My problem was

Re: What is executed when in a generator

2005-10-04 Thread Steve Holden
Jerzy Karczmarczuk wrote: > I thought that the following sequence > > gl=0 > def gen(x): > global gl > gl=x > yield x > > s=gen(1) > > suspends the generator just before the yield, so after the > assignment of s gl becomes 1. > > Well, no. It is still zero. If I put > > print "s

Re: What is executed when in a generator

2005-10-04 Thread Matt Hammond
On Tue, 04 Oct 2005 12:48:03 +0100, Jerzy Karczmarczuk <[EMAIL PROTECTED]> wrote: > before the yield, this doesn't get executed either. *EVERYTHING* > from the beginning until the yield gets executed only upon s.next(). > > Could you tell me please where can I read something in depth about the >

Re: What is executed when in a generator

2005-10-04 Thread Fredrik Lundh
Jerzy Karczmarczuk wrote: > Could you tell me please where can I read something in depth about the > semantics of generators? I feel a bit lost. the behaviour is described in the language reference manual: http://docs.python.org/ref/yield.html "When a generator function is called, it re