<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 26, 2017, at 1:45 AM, Craig Rodrigues <<a href="mailto:rodrigc@crodrigues.org" class="">rodrigc@crodrigues.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 25, 2017 at 10:06 AM, Phil Mayers <span dir="ltr" class=""><<a href="mailto:p.mayers@imperial.ac.uk" target="_blank" class="">p.mayers@imperial.ac.uk</a>></span> wrote:<br class=""><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-"><br class=""></span>
Related, see:<br class="">
<br class="">
<a href="http://stackoverflow.com/questions/32139885/yield-in-list-comprehensions-and-generator-expressions" rel="noreferrer" target="_blank" class="">http://stackoverflow.com/quest<wbr class="">ions/32139885/yield-in-list-<wbr class="">comprehensions-and-generator-<wbr class="">expressions</a><br class="">
<br class="">
<a href="http://bugs.python.org/issue10544" rel="noreferrer" target="_blank" class="">http://bugs.python.org/issue10<wbr class="">544</a><br class="">
<br class="">
Basically, don't use yield inside comprehensions if you don't want weirdness, AFAICT :o/<br class="">
<br class=""></blockquote><div class=""><br class=""></div><div class="">Yes, that's the exact issue!</div><div class="">Pointed out to me on the python-dev list:</div><div class=""><br class=""></div><div class=""><a href="https://mail.python.org/pipermail/python-dev/2017-January/147242.html" class="">https://mail.python.org/pipermail/python-dev/2017-January/147242.html</a><br class=""></div><div class=""><br class=""></div><div class="">My vote is that this is a bug in Python.</div></div></div></div></div></blockquote><br class=""></div><div>Discussing on that bug, I discovered that this is sort-of fixed in python 3.6; not for generators, but for coroutines. You can have an 'async def' function that does 'await' inside a generator and it should work.</div><div><br class=""></div><div>Note that this is new in 3.6, and doesn't work in 3.5.</div><div><br class=""></div><div>-glyph</div><br class=""></body></html>