<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 4, 2018 at 11:04 PM, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Mar 5, 2018 at 2:49 PM, Mike Miller <<a href="mailto:python-ideas@mgmiller.net">python-ideas@mgmiller.net</a>> wrote:<br>
> Yes, thanks:<br>
><br>
> [ f(y), g(y) for x, h(x) as y in things ]<br>
><br>
><br>
> Dyslexics untie!<br>
<br>
</span>:)<br>
<br>
Hmm. The trouble here is that a 'for' loop is basically doing<br>
assignment. When you say "for x, h(x) as y in things", what Python<br>
does is (simplified):<br>
<br>
_it = iter(things)<br>
while not StopIteration:<br>
x, (h(x) as y) = next(_it)<br>
... loop body ...<br>
<br>
So what you're asking for is something that doesn't behave like an<br>
assignment target, but just does its own assignment. Bear in mind,<br>
too, that "x = next(_it)" is very different from "x, = next(_it)";<br>
which one is "x, (h(x) as y) = next(_it)" more like?<br>
<br></blockquote><div><br></div><div>If I understood Mike's proposal correctly it was to allow "," to mean 'given' in this context when followed by EXPRESSION "as" VARIABLE, rather than its usual iterable-unpacking meaning.<br></div><div> <br><div>But I think this would cause confusion. Suppose `things` contains pair-tuples. Then you could have<br><br></div><div> [ f(y), g(y) for x1, x2, h(x1) as y in things ]<br><br></div><div>which makes it look like (x1, x2, h(x1)) go together rather than just (x1, x2).<br></div><br></div><div>Nathan<br></div></div><br></div></div>