[Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

Guido van Rossum guido at python.org
Sun Apr 8 12:28:30 EDT 2018


On Sun, Apr 8, 2018 at 8:01 AM, Steven D'Aprano <steve at pearwood.info> wrote:

> If we really wanted to keep the sublocal scoping, we could make
> list/set/dict displays their own scope too.
>
> Personally, that's the only argument for sublocal scoping that I like
> yet: what happens inside a display should remain inside the display, and
> not leak out into the function.
>

That sounds like a reasonable proposal that we could at least consider. But
I think it will not fly. Presumably it doesn't apply to tuple displays,
because of reasonable examples like ((a := f(), a+1), a+2), and because it
would create an ugly discontinuity between (a := f()) and (a := f(),). But
then switching between [a := f(), a] and (a := f(), a) would create a
discontinuity.

For comprehensions and generator expressions there is no such discontinuity
in the new proposal, since these *already* introduce their own scope.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180408/3a86c639/attachment.html>


More information about the Python-ideas mailing list