Python nonlocal statement
Compare this, without using nonlocal: To this, using nonlocal, where inner()‘s x is now also outer()‘s x: If we were to use global, it would bind x to the properly “global” value:
Compare this, without using nonlocal: To this, using nonlocal, where inner()‘s x is now also outer()‘s x: If we were to use global, it would bind x to the properly “global” value: