On 25 March 2018 at 17:18, Chris Angelico <ros...@gmail.com> wrote:
> Agreed. I'm currently thinking that I need to do what several people
> have suggested and break this into two completely separate PEPs:
>
> 1) Sublocal namespacing
> 2) Assignment expressions
>
> Sublocal names can be used in a number of ways. There could be a "with
> sublocal EXPR as NAME:" syntax that actually disposes of the name
> binding at the end of the block,

The scoping affects the name binding rather than the expression
evaluation, so I'd expect any such variant to be:

    with EXPR as sublocal NAME:
        ...

> and "except Exception as e:" could
> shadow rather than unbinding. Maybe list comprehensions could change,
> too - instead of creating a function, they just create a sublocal
> scope.
>
> That may be the best way forward. I'm not sure.

I think you can treat it as an open design question within the current
PEP by tweaking the PEP title to be "Name binding as an expression".

If we allow expression level name binding at all, it will be an
either/or choice between binding to a new sublocal scope and binding
regular locals, and you can handle that by describing sublocals as
your current preferred option, but point out that the same *syntactic*
idea could be adopted without introducing the sublocals semantics (in
the latter case, the distinction created by the PEP would just be
between "assignment statements" and "assignment expressions", rather
than between "local assignments" and "sublocal assignments").

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to