<div dir="ltr">On 22 November 2017 at 17:50, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 22 November 2017 at 16:38, Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>> wrote:<br>
> On 22 November 2017 at 17:16, Paul Moore <<a href="mailto:p.f.moore@gmail.com">p.f.moore@gmail.com</a>> wrote:<br>
>><br>
</span><span class="">>> Docs more importantly than PEP IMO. And are you implying that there's<br>
>> a difference between generator expressions and comprehensions? I<br>
>> thought both were intended to behave as if expanded to a function<br>
>> containing nested for loops? Nothing said in this thread so far (about<br>
>> semantics, as opposed to about current behaviour) implies there's a<br>
>> deliberate difference.<br>
><br>
><br>
> I think there may be a difference:<br>
><br>
> comprehension `g = [(yield i) for i in range(3)]` is defined as this code:<br>
><br>
> __result = []<br>
> __i = None<br>
> try:<br>
> for __i in range(3):<br>
> __result.append(yield __i)<br>
> g = __result<br>
> finally:<br>
> del __result, __i<br>
<br>
</span>Not in the docs, it isn't... </blockquote><div><br></div><div>Yes, since there is almost nothing there, this is what I _propose_ (or actually Serhiy proposed it first)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The docs explicitly state that a new<br>
scope is involved.<br></blockquote><div><br></div><div>But docs don't say it is a _function_ scope. The meaning of that statement (as I understand it) is just that the loop variable doen't leak from comprehension.</div><div><br></div><div>--</div><div>Ivan</div><div><br></div><div><br></div></div></div></div>