[Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

Nick Coghlan ncoghlan at gmail.com
Sat Mar 24 04:53:53 EDT 2018


On 24 March 2018 at 04:09, Chris Angelico <rosuav at gmail.com> wrote:

> On Sat, Mar 24, 2018 at 2:00 AM, Steven D'Aprano <steve at pearwood.info>
> wrote:
> > I see you haven't mentioned anything about Nick Coglan's (long ago)
> > concept of a "where" block. If memory serves, it would be something
> > like:
> >
> >     value = x**2 + 2*x where:
> >         x = some expression
> >
> > These are not necessarily competing, but they are relevant.
>
> Definitely relevant, thanks. This is exactly what I'm looking for -
> related proposals that got lost in the lengthy threads on the subject.
> I'll mention it as another proposal, but if anyone has an actual post
> for me to reference, that would be appreciated (just to make sure I'm
> correctly representing it).
>

That one's a PEP reference: https://www.python.org/dev/peps/pep-3150/

If PEP 572 were to happen, then I'd see some variant of PEP 3150 as a
potential future follow-on (allowing the statement local namespace for a
simple statement to be populated in a trailing suite, without needing to
make the case for statement locals in the first place).

If inline local variable assignment were to happen instead, then PEP 3150
would continue to face the double hurdle of pitching both the semantic
benefits of statement locals, while also pitching a syntax for defining
them.

FWIW, I like this version of the statement local proposal, and think it
would avoid a lot of the quirks that otherwise arise when allowing
expression level assignments.

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/20180324/6f16f4c1/attachment.html>


More information about the Python-ideas mailing list