nonlocal statement makes it clear when data is being assigned out of a closure into another scope. It’s complementary to the
global statement, which indicates that a variable’s assignment should go directly into the module scope.
However, much like the anti-pattern of global variables, I’d caution against using
nonlocal for anything beyond simple functions. The side effects of
nonlocal can be hard to follow. It’s especially hard to understand in long functions where the
nonlocal statements and assignments to associated variables are far apart.
- 2. Functions
- from Effective Python: 59 Specific Ways to Write Better Python
- Publisher: Addison-Wesley Professional
- Released: March 2015
check this out for next week project
Share this highlighthttp://www.safaribooksonline.com/a/effective-python-59/329573/