Nested ScopesIn Python 2.1, nested functions defined nested scopes
Exampledef foo(): x = 1 def bar(): print x # Use of nonlocal variable while x < 10: bar() x += 1 In previous versions of Python
In Python 2.1: It works! |
<<< | O'Reilly OSCON 2001, New Features in Python 2, Slide 18 July 26, 2001, beazley@cs.uchicago.edu |
>>> |