[Python-ideas] Fixing class scope brainstorm
Elazar
elazarg at gmail.com
Sun Mar 25 12:42:52 EDT 2018
On Sun, Mar 25, 2018 at 5:51 PM Guido van Rossum <guido at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180325/2a7bcb52/attachment.html>
More information about the Python-ideas
mailing list