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/1b34a866/attachment.html below:

<div dir="ltr">On 23 November 2017 at 13:45, 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"><div class="HOEnZb"><div class="h5">On 23 November 2017 at 12:28, Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>> wrote:<br>
> On 23 November 2017 at 13:11, Paul Moore <<a href="mailto:p.f.moore@gmail.com">p.f.moore@gmail.com</a>> wrote:<br>
>><br>
>> On 23 November 2017 at 12:01, Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>><br>
>> wrote:<br>
>><br>
>> > "I don't use it, therefore it is not needed"  is a great argument,<br>
>> > thanks.<br>
>> > Lets just forget about two SO questions and dozens people who up-voted<br>
>> > it.<br>
>> > Do you use async comprehensions? If not, then we don't need them either.<br>
>><br>
>> For those of us trying to keep up with the discussion who don't have<br>
>> time to chase the various references, and in the interest of keeping<br>
>> the discussion in one place, can you summarise the real-world use<br>
>> cases from the SO questions here? (I assume they are real world cases,<br>
>> and not just theoretical questions)<br>[...]<br>
><br>
> My understanding is that none of the case is _pressing_, since they all<br>
> start with a for-loop, but<br>
> following this logic comprehensions themselves are not needed. Nevertheless<br>
> people use them because they like it.<br>
> The problem in all four cases is that they got hard to debug problem, since<br>
> calling `f()` returns a generator,<br>
> just not the one they would expect.<br>
<br>
</div></div>OK, thanks. I can see why someone would want to do this. However, it<br>
seems to me that the problem (a hard to debug error) could be solved<br>
by disallowing yield in comprehensions and generator expressions<br>
(giving an *easy* to debug error). I don't think the above is a<br>
compelling argument that we have to support the one-line form. If<br>
there was a non-trivial body of actual user code that uses the loop<br>
form, which would be substantially improved by being able to use<br>
comprehensions, that would be different. To put it another way, the<br>
example you gave is still artificial. The second link is a real use<br>
case, but as you say seems to be more a question about "why did this<br>
not work as I expected" which could be solved with a SyntaxError<br>
saying "yield expression not allowed in comprehensions".<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>The level of "artificialness" is quite subjective, this is rather matter of taste (see the tornado example).</div><div>Let us forget for a moment about other problems and focus on this one: list comprehension is currently not equivalent to a for-loop.</div><div>There are two options:</div><div>- Fix this, i.e. make comprehension equivalent to a for-loop even in edge cases (Serhiy seems ready to do this)</div><div>- Prohibit all cases when they are not equivalent<br></div></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">I still prefer option one. But I see your point, option two is also an acceptable fix.</div><div class="gmail_extra">Note that there were not so many situations when some code became SyntaxError later.</div><div class="gmail_extra">I don't see why this particular case qualifies for such a radical measure as an exception to syntactic rules,</div><div class="gmail_extra">instead of just fixing it (sorry Nick :-)</div><div class="gmail_extra"><br></div><div class="gmail_extra">--</div><div class="gmail_extra">Ivan</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></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