New submission from Yoong Hor Meng <yoon...@gmail.com>:
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. ---------- components: Interpreter Core messages: 333510 nosy: yoonghm priority: normal severity: normal status: open title: Using for...in.. generator-iterator type: behavior versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35725> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com