<div dir="ltr">Yes, exactly. Wouldn't that be a useful built-in?<div><br></div><div>(And, is this really the first time this idea is being discussed?)<br><br>Thanks,<br>Josh<br><br>On Saturday, June 23, 2018 at 9:12:35 PM UTC-4, Nathaniel Smith wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Sat, Jun 23, 2018 at 5:58 PM, Greg Ewing <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="SqK6bTbsAwAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">greg....@canterbury.ac.nz</a>> wrote:
<br>> <a href="javascript:" target="_blank" gdf-obfuscated-mailto="SqK6bTbsAwAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">j...@math.brown.edu</a> wrote:
<br>>>
<br>>> it would be nice if we could write an async version of this, as in ``async
<br>>> for chunk in aiter(...)``.
<br>>
<br>> The time machine seems to have taken care of this:
<br>>
<br>> <a href="https://docs.python.org/3.6/reference/compound_stmts.html#the-async-for-statement" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fdocs.python.org%2F3.6%2Freference%2Fcompound_stmts.html%23the-async-for-statement\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNETd8c6w27w0CoTZBYJb5tGg7CLhA';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fdocs.python.org%2F3.6%2Freference%2Fcompound_stmts.html%23the-async-for-statement\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNETd8c6w27w0CoTZBYJb5tGg7CLhA';return true;">https://docs.python.org/3.6/<wbr>reference/compound_stmts.html#<wbr>the-async-for-statement</a>
<br>
<br>He's asking for an async version of the 'iter' builtin, presumably
<br>something like:
<br>
<br>async def aiter(async_callable, sentinel):
<br>    while True:
<br>        value = await async_callable()
<br>        if value == sentinel:
<br>            break
<br>        yield value
<br>
<br>-n
<br>
<br>-- 
<br>Nathaniel J. Smith -- <a href="https://vorpus.org" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fvorpus.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGu9BH-CNkjUnoU8qy5kxnhJP302A';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fvorpus.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGu9BH-CNkjUnoU8qy5kxnhJP302A';return true;">https://vorpus.org</a>
<br>______________________________<wbr>_________________
<br>Python-ideas mailing list
<br><a href="javascript:" target="_blank" gdf-obfuscated-mailto="SqK6bTbsAwAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">Python...@python.org</a>
<br><a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-ideas\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-ideas\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return true;">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a>
<br>Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fpython.org%2Fpsf%2Fcodeofconduct%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fpython.org%2Fpsf%2Fcodeofconduct%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return true;">http://python.org/psf/<wbr>codeofconduct/</a>
<br></blockquote></div></div>