A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20171123/c3dcd503/attachment.html below:

<div dir="ltr">On 23 November 2017 at 15:21, 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 13:04, Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>> wrote:<br>
> Let us forget for a moment about other problems and focus on this one: list<br>
> comprehension is currently not equivalent to a for-loop.<br>
> There are two options:<br>
> - Fix this, i.e. make comprehension equivalent to a for-loop even in edge<br>
> cases (Serhiy seems ready to do this)<br>
> - Prohibit all cases when they are not equivalent<br>
><br>
> I still prefer option one. But I see your point, option two is also an<br>
> acceptable fix.<br>
> Note that there were not so many situations when some code became<br>
> SyntaxError later.<br>
> I don't see why this particular case qualifies for such a radical measure as<br>
> an exception to syntactic rules,<br>
> instead of just fixing it (sorry Nick :-)<br>
<br>
</span>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></blockquote><div><br></div><div>Absolutely no, it will still print 1. The internal implementation will use unique ids internally (see <a href="https://bugs.python.org/issue10544">https://bugs.python.org/issue10544</a> for details).</div><div><br></div><div>--</div><div>Ivan</div><div><br></div><div><br></div></div></div></div>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4