This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yoonghm
Recipients yoonghm
Date 2019-01-12.04:26:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547267184.5.0.152784183529.issue35725@roundup.psfhosted.org>
In-reply-to
Content
def f():
    print('-- Start --')
    yield 1
    print('-- Middle --')
    yield 2
    print('-- Finished --')
    yield 3

gen = f()
for x in gen:
    print('Another things ...')
    next(gen)


The output:

-- Start --
Another things ...
-- Middle --
-- Finished --
Another things ...

I noticed that the generator function will execute whenever it is in the for...in loop.  Is it expected? I do not see it documented anywhere. Thanks.
History
Date User Action Args
2019-01-12 04:26:26yoonghmsetrecipients: + yoonghm
2019-01-12 04:26:24yoonghmsetmessageid: <1547267184.5.0.152784183529.issue35725@roundup.psfhosted.org>
2019-01-12 04:26:24yoonghmlinkissue35725 messages
2019-01-12 04:26:24yoonghmcreate