<div dir="ltr">On 23 November 2017 at 15:30, 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 23 November 2017 at 14:24, Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>> wrote:<br>
>> My main concern is that comprehension is not equivalent to a for loop<br>
>> for a specific reason - the scope issue. Has anyone looked back at the<br>
>> original discussions to confirm *why* a function was used?<br>
>><br>
>> My recollection:<br>
>><br>
>> >>> i = 1<br>
>> >>> a = [i for i in (1,2,3)]<br>
>> >>> print(i)<br>
>> 1<br>
>><br>
>> Serihy's approach (and your described expansion) would have print(i)<br>
>> return NameError.<br>
><br>
><br>
> Absolutely no, it will still print 1. The internal implementation will use<br>
> unique ids internally (see <a href="https://bugs.python.org/issue10544" rel="noreferrer" target="_blank">https://bugs.python.org/<wbr>issue10544</a> for details).<br>
><br>
<br>
</span>Ok, cool. My main point still applies though - has anyone confirmed<br>
why a function scope was considered necessary at the time of the<br>
original implementation, but it's apparently not now? I'm pretty sure<br>
it was a deliberate choice, not an accident.</blockquote><div><br></div><div>From what Nick explained on b.p.o. I understand that this is closer to the "accident" definition.</div><div>Also the original issue <a href="https://bugs.python.org/issue1660500">https://bugs.python.org/issue1660500</a> doesn't have any discussion of the implementation _strategy_.<br></div><div>So I tried to dig the mailing list, in the latest Guido's message I have found<br></div><div><a href="https://mail.python.org/pipermail/python-3000/2006-December/005218.html">https://mail.python.org/pipermail/python-3000/2006-December/005218.html</a></div><div>he still likes the idea of unique hidden ids (like Serhiy proposes now) and no function scopes. After that there is Nick's message</div><div><a href="https://mail.python.org/pipermail/python-3000/2006-December/005229.html">https://mail.python.org/pipermail/python-3000/2006-December/005229.html</a> where he says that he still likes pseudo-scopes more.<br></div><div>Then I lost the track of discussion.</div><div><br></div><div>It may well be Nick's intentional decision (and it has its merits) but I am not sure it was a conscious consensus.</div><div>Nick could probably add more. Also I propose to wait and see when Serhiy will show us his complete implementation.</div><div><br></div><div>--</div><div>Ivan</div><div><br></div><div><br></div></div></div></div>