Message333510
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. |
|
Date |
User |
Action |
Args |
2019-01-12 04:26:26 | yoonghm | set | recipients:
+ yoonghm |
2019-01-12 04:26:24 | yoonghm | set | messageid: <1547267184.5.0.152784183529.issue35725@roundup.psfhosted.org> |
2019-01-12 04:26:24 | yoonghm | link | issue35725 messages |
2019-01-12 04:26:24 | yoonghm | create | |
|