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 "something"

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
semantics of generators? I feel a bit lost.
Thank you.


Jerzy Karczmarczuk
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to