Passing argument from Parent function to nested function Python
You are understanding it correctly. You cannot use x to assign to in a nested scope in Python 2. In Python 3, you can still use it as a binding occurrence by marking the variable as nonlocal; this is a keyword introduced for just this usecase: def f(x): def g(n): nonlocal x if n < … Read more