[Python-Dev] Unbound locals in class scopes
levkivskyi at gmail.com
Mon Jun 22 00:46:07 CEST 2015
On 21 June 2015 at 22:05, Guido van Rossum <guido at python.org> wrote:
> On Sun, Jun 21, 2015 at 6:22 PM, Ivan Levkivskyi <levkivskyi at gmail.com>
>> It is still not clear whether Guido's comment still stands for not
raising an UnboundLocalError in class definitions but using globals instead.
> Can you phrase this in the form of an example, showing what it currently
does and what you think it should do, instead?
Here is an example:
x = "xtop"
y = "ytop"
x = "xlocal"
y = "ylocal"
y = 1
Intuitively, one might think that it should raise UnboundLocalError or
print ylocal instead of ytop.
This question was discussed 13 years ago and then you said that this lookup
is an intentional behavior.
This behavior is not documented, and I started an issue on bug tracker
about documenting it.
Then, Eric proposed to ask you again, whether this is still an intentional
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev