
When a Python generator yields, its stack frame remains — inspect it for the current line and local variables:
def fib():
x = 0
y = 1
while True:
yield x
x, y = y, x+y
g = fib()
next(g)
g.gi_frame.f_locals # returns {'x': 0, 'y': 1}
