On Wed, Jun 27, 2018 at 9:27 AM Paul Moore <p.f.mo...@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)] print(x) 3 def f(): x = 4 y = [x := 5 for i in range(1)] print(x) f() 5 class C: x = 6 y = [x := 7 for i in range(1)] print(x) C() 6 print(x) 7
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com