On 21 June 2015 at 22:05, Guido van Rossum <gu...@python.org> wrote:
>
> On Sun, Jun 21, 2015 at 6:22 PM, Ivan Levkivskyi <levkivs...@gmail.com>
wrote:
>>
>> 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"
def func():
    x = "xlocal"
    y = "ylocal"
    class C:
        print(x)
        print(y)
        y = 1
func()

prints

xlocal
ytop

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
in globals
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
behavior.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to