[Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
On Sun, Jun 24, 2018 at 11:50 AM Steven D'Aprano <steve at pearwood.info>
> > [...] IIRC (b) originated with Tim.
> I'm not sure who came up with the idea first, but as I remember it, the
> first mention of this came in a separate thread on Python-Ideas:
> so possibly I'm to blame :-)
Actually that post sounds like the OP of that thread (Peter O'Connor) is to
blame -- he proposed a similar thing using `=` for the assignment and
custom syntax (`from <value>`) to specify the initial value, and it looks
like that inspired you.
> > But his essay on the topic, included as Appendix A (
> > does not even mention comprehensions. However, he did post his motivation
> > for (b) on python-ideas, IIRC a bit before PyCon; and the main text of
> > PEP gives a strong motivation (
> > https://www.python.org/dev/peps/pep-0572/#scope-of-the-target).
> > Nevertheless, maybe we should compromise and drop (b)?
> I will have more to say about the whole "comprehensions are their own
> scope" issue later. But I'd like to see Nick's proposed PEP, or at least
> a draft of it, before making any final decisions.
Agreed, though I assume it's just `given` again.
> If it came down to it, I'd be happy with the ability to declare an
> assignment target nonlocal in the comprehension if that's what it takes.
> What do you think of this syntax?
> [global|nonlocal] simple_target := expression
> Inside a comprehension, without a declaration, the target would be
> sublocal (comprehension scope); that should make Nick happier :-)
It's more special syntax. Just taking part (a) of PEP 572 would make most
people happy enough.
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...