On Sun, Apr 8, 2018 at 8:01 AM, Steven D'Aprano <steve@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)