def a():
    yield lambda : i
for i in range(100):
    yield
g = a()
f = next(g)
f()
next(g)
f()
next(g)
f()
f.__closure__
f.__closure__[0].cell_contents
Python: lambda function behavior with and without keyword arguments?