[Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part) (original) (raw)
Eric Fahlgren ericfahlgren at gmail.com
Wed Jun 27 16:46:10 EDT 2018
- Previous message (by thread): [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
- Next message (by thread): [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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)] 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180627/a7ecbbf5/attachment.html>
- Previous message (by thread): [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
- Next message (by thread): [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]