I have created a nested closure which looks as below:
def incrementer(n):
def inner(start):
current = start
def inc():
nonlocal current
current += n
return current
return inc
return inner
fn = incrementer(2)
Now, when I print value of co_freevars for fn I get below output:
print(fn.__code__.co_freevars) -> ('n',)
My understanding is that it should be ('current', 'n') because there are 2 free variables
here.
Why print(fn.__code__.co_freevars) is not printing ('current', 'n')?