Problem/bug with class definition inside function definition

Gregory Ewing greg.ewing at canterbury.ac.nz
Wed May 9 01:38:35 EDT 2018


Alexey Muranov wrote:
>    x = 42
> 
>    class C:
>        x = x  # Works

I'd say it kind of works by accident, and is not really an
intended feature.

> if Python does not allow to refer "simultaneously" to 
> variables from different scopes if they have the same name.

It seems perfectly reasonable to me to have to use different
names to refer to different things in the same context. :-)

-- 
Greg



More information about the Python-list mailing list