nonlocal Scope
Let's briefly understand the nonlocal scope in python.
We'll cover the following...
Python 3 added a new keyword called nonlocal. The nonlocal keyword adds a scope override to the inner scope. We can read all about it in PEP 3104. This is best illustrated with a couple of code examples. One of the most common examples is to create function that can increment:
Press + to interact
def counter():num = 0def incrementer():num += 1return numreturn incrementer
If we try ...