On Sun, Mar 25, 2018 at 5:51 PM Guido van Rossum <gu...@python.org> wrote:

> In the PEP 572 threads there's some grumbling about class scopes.
>
> Here's a random brainstorm. How about we change the scoping rules so that
> only functions defined with 'def' (or inside one of those) cannot see the
> class scope, and comprehensions and lambdas treat the class scope as an
> outer scope so they can close over class variables?
>
> Not sure what should happen to nested classes, they should probably be
> lumped in with the 'def' scopes.
>
>
I would expect classes to behave like comprehensions - i.e. code that is
not delayed will see the class' scope as an enclosing scope (since it is
not namespaced yet so there's no other way to refer to it) and delayed code
(e.g. lambdas or defs) will not.

Elazar
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to