Showing content from http://mail.python.org/pipermail/python-dev/attachments/20171125/93d73ca7/attachment.html below:
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Nov 25, 2017 at 8:07 AM, Ivan Levkivskyi <span dir="ltr"><<a href="mailto:levkivskyi@gmail.com" target="_blank">levkivskyi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On 25 November 2017 at 16:57, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><span class="">On Sat, Nov 25, 2017 at 6:55 AM, Ivan Levkivskyi <span dir="ltr"><<a href="mailto:levkivskyi@gmail.com" target="_blank">levkivskyi@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><span class="m_-2527567930407236489m_7904138329541714044gmail-">On 25 November 2017 at 04:30, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="m_-2527567930407236489m_7904138329541714044gmail-m_-321702978631925968gmail-">On Fri, Nov 24, 2017 at 4:22 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br></span><span class="m_-2527567930407236489m_7904138329541714044gmail-m_-321702978631925968gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">The more I hear about this topic, the more I think that `await`, `yield` and `yield from` should all be banned from occurring in all comprehensions and generator expressions. That's not much different from disallowing `return` or `break`.<span></span><br></div></blockquote></span></div><br clear="all"></div><div class="gmail_extra">From the responses it seems that I tried to simplify things too far. Let's say that `await` in comprehensions is fine, as long as that comprehension is contained in an `async def`. While we *could* save `yield [from]` in comprehensions, I still see it as mostly a source of confusion, and the fact that the presence of `yield [from]` *implicitly* makes the surrounding `def` a generator makes things worse. It just requires too many mental contortions to figure out what it does.</div></div></blockquote><div><br></div></span></span>[...]<span class=""><br><div>If the first example will be allowed, then one will be surprised why it can't be rewritten as</div><div><br></div><div><div>Â Â Â def pack_two():</div>Â Â Â Â Â Â Â return [(yield) for _ in range(2)]</div></span></div></div></div></blockquote></span><span class=""><span><div><br></div></span><div>And yet Nick's example shows that that is not equivalent!</div></span><span><div><br></div><div>[...]<br></div><div><br></div></span><span class=""><div>In this example each thing that looks syntactically like a list comprehension becomes actually a generator expression at at runtime! And so does your example, so instead of a list of two items, it returns a generator that will produce two values when iterated over.</div><div><br></div><div>That's not referential transparency to me, it feels more like a bug in the code generator.</div><div><br></div><div>I want to ban this because apparently nobody besides Nick knows about this behavior (I certainly didn't, and from the above it seems you don't either).<br></div><span></span></span></div></div></div></blockquote><div><br></div><div>This whole thread started as a proposal to fix this bug and to make the two forms equivalent, so I don't know what you are talking about.</div></div></div></div></blockquote><div><br></div><div>I see. I misread your equivalence example as "this how it works" -- you meant it as "this is how I propose we fix it".</div><div><br></div><div>The fix is not unreasonable but I still would like to retreat to the territory where `yield [from]` in comprehensions (and generator expressions) is deemed invalid.<br></div><div>Â </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Also as there appeared arguments of authority (thanks Antoine) its time to stop this discussion for me.<br></div></div></div></div></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">I'd be happy to stop with the conclusion that we're going to rip out some confusing syntax rather than trying to generate code for it -- IMO we've proved to ourselves that this stuff is too complicated to be useful.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</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