[Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
ericfahlgren at gmail.com
Wed Jun 27 16:46:10 EDT 2018
On Wed, Jun 27, 2018 at 9:27 AM Paul Moore <p.f.moore at gmail.com> wrote:
> From my reading, PEP 572 takes the position that "parent local
> scoping" is what people expect from assignment expressions *in
> comprehensions* and it's useful enough that there is no reason not to
> make that the behaviour. The behaviour isn't generally useful enough
> to be worth exposing as a primitive (it's not even useful enough for
> the PEP to give it an explicit name!) so it's just a special case for
> assignment expressions in comprehensions/generators.
So, my interpretation is that it will behave like this?
x = 2
y = [x := 3 for i in range(1)]
x = 4
y = [x := 5 for i in range(1)]
x = 6
y = [x := 7 for i in range(1)]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev