[issue12023] non causal behavior

Ezio Melotti report at bugs.python.org
Sat May 7 00:57:15 CEST 2011


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

The reason is that in nok Python sees the assignment to a (a = 1) and determines that the 'a' variable is local to the scope of f, and since the assignment comes after the "if a:" and at that point 'a' has no value, an error is raised.
In ok there's no assignment to 'a', so Python assume that 'a' refers to the 'a' variable defined in the outer scope.

----------
nosy: +ezio.melotti
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12023>
_______________________________________


More information about the Python-bugs-list mailing list