I have this experimental code:
def f():
print("Line 1")
yield
print("Line 2")
yield
print("Line 3")
yield
f()
f()
f()
All I see on the screen is <generator object f at 0x7d8239c794d0>
. I expected that each print statement would execute, then execution pauses at each yield
line until f()
is called again. But this is not the case, why is that? What am I misunderstanding?
8