Author rhettinger
Recipients
Date 2007-07-16.07:51:40
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Miki, I don't see a bug here.  The presence of "yield" is significant during compilation not just when the line is executed.  When the yield appears anywhere in a function body, it is not a function anymore, it is a generator.  So, when the "yield" is uncommented, the call to one_pass returns a generator which doesn't start running until its next() method is called.  In contrast, when the "yield" is commented, you have a function that starts running immediately when one_pass() is called.

Here is a simplified comparison of the generator versus function:

>>> def one_pass():
...     print 'running'
...     yield 1
...
>>> g = one_pass()
>>> g.next()
running
1
>>> def one_pass():
...     print 'running'
...     # yield 1
...
>>> one_pass()
running


If you still see a bug, please elaborate.  If not, please close this report.
History
Date User Action Args
2007-08-23 14:58:39adminlinkissue1754456 messages
2007-08-23 14:58:39admincreate