Local functions in Python [duplicate]
I believe you’re correct in seeing this as a “mutability” problem. While the code you posted does throw an “UnboundLocalError”, the following code does not: def outer(): a = 0 def inner(): print a inner() outer() Python doesn’t allow you to reassign the value of a variable from an outer scope in an inner scope … Read more