[Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part) (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Wed Jun 27 10:39:38 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 27 June 2018 at 23:38, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
Nick Coghlan wrote:
actually made those semantics available as an explicit "parentlocal NAME" declaration ...: def listcomp(outermostiter): parentlocal item result = [] for x in outermostiter: item = x result.append(x) return result exprresult = listcomp(items) I'm not sure that's possible. If I understand correctly, part of the definition of "parent local" is that "parent" refers to the nearest enclosing non-comprehension scope, to give the expected result for nested comprehensions. If that's so, then it's impossible to fully decouple its definition from comprehensions.
I'm OK with a target scope declaration construct having lexical-scope-dependent behaviour - exactly what "nonlocal NAME" will do depends on both the nature of the current scope, and on which names are declared as local in which outer scopes, and that's also implicitly the case for all name lookups.
However, PEP 572 in its current form takes the position "parent local scoping is sufficiently useful to make it a required pre-requisite for adding assignment expressions, but not useful enough to expose as a new scope declaration primitive", and I've come to the view that it really is the "A+B=MAGIC!" aspect of the current proposal that bothers me, whereas "A+B implies C for " doesn't bother me any more than the implicit non-local references introduced as part of the original lexical scoping changes bother me.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- 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 ]