[Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

Nick Coghlan ncoghlan at gmail.com
Sat Mar 3 02:45:16 EST 2018


On 3 March 2018 at 11:36, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

> 1. Name bindings local to an expression:
>
>    roots = ([(-b-r)/(2*a), (-b+r)/(2*a)] where r = sqrt(b*b-4*a*c))
>
> B. In an expression, surrounded by parentheses for
> disambiguation. Bindings are visible only within the
> parentheses.
>

I'll note that a significant benefit of this approach over the PEP 572
approach is that it would be amenable to a comprehension style
scope-management solution: these expressions could create an implicitly
nested function and immediately call it, just as 3.x comprehensions do.
Adopting such an approach would *dramatically* lower the impact that hiding
the bindings from the surrounding scope would have on the overall name
resolution semantics.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180303/df4065a8/attachment-0001.html>


More information about the Python-ideas mailing list