__future__
New language features now enabled by a special module
from __future__ import nested_scopes
Intent is to first introduce features that might break old code as optional
Features enabled by __future__ will eventually be enabled by default
To help find problems, warnings are generated for problematic code
>>> def foo():
... def bar():
... print x
... exec "x = 1"
<stdin>:1: SyntaxWarning: unqualified exec is not allowed in function
'foo' it contains a nested function with free variables
>>> from __future__ import nested_scopes
>>> def foo():
... def bar():
... print x
... exec "x = 1"
SyntaxError: unqualified exec is not allowed in function 'foo' it contains
a nested function with free variables
|