<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Jun 24, 2018 at 11:50 AM Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[Guido] <br>> [...] IIRC (b) originated with Tim. <br>
<br>
I'm not sure who came up with the idea first, but as I remember it, the <br>
first mention of this came in a separate thread on Python-Ideas:<br>
<br>
<a href="https://mail.python.org/pipermail/python-ideas/2018-April/049631.html" rel="noreferrer" target="_blank">https://mail.python.org/pipermail/python-ideas/2018-April/049631.html</a><br>
<br>
so possibly I'm to blame :-)<br></blockquote><div><br></div><div>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.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> But his essay on the topic, included as Appendix A (<br>
> <a href="https://www.python.org/dev/peps/pep-0572/#appendix-a-tim-peters-s-findings" rel="noreferrer" target="_blank">https://www.python.org/dev/peps/pep-0572/#appendix-a-tim-peters-s-findings</a>)<br>
> does not even mention comprehensions. However, he did post his motivation<br>
> for (b) on python-ideas, IIRC a bit before PyCon; and the main text of the<br>
> PEP gives a strong motivation (<br>
> <a href="https://www.python.org/dev/peps/pep-0572/#scope-of-the-target" rel="noreferrer" target="_blank">https://www.python.org/dev/peps/pep-0572/#scope-of-the-target</a>).<br>
> Nevertheless, maybe we should compromise and drop (b)?<br>
<br>
I will have more to say about the whole "comprehensions are their own <br>
scope" issue later. But I'd like to see Nick's proposed PEP, or at least <br>
a draft of it, before making any final decisions.<br></blockquote><div><br></div><div>Agreed, though I assume it's just `given` again.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If it came down to it, I'd be happy with the ability to declare an <br>
assignment target nonlocal in the comprehension if that's what it takes. <br>
What do you think of this syntax?<br>
<br>
    [global|nonlocal] simple_target := expression<br>
<br>
Inside a comprehension, without a declaration, the target would be <br>
sublocal (comprehension scope); that should make Nick happier :-)<br></blockquote><div><br></div><div>It's more special syntax. Just taking part (a) of PEP 572 would make most people happy enough.<br></div><div> </div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)</div></div>