Re: [Python-ideas] Replacing Infinite while Loops with an Iterator: async edition
Yes, exactly. Wouldn't that be a useful built-in? (And, is this really the first time this idea is being discussed?) Thanks, Josh On Saturday, June 23, 2018 at 9:12:35 PM UTC-4, Nathaniel Smith wrote: > > On Sat, Jun 23, 2018 at 5:58 PM, Greg Ewing > wrote: > > j...@math.brown.edu wrote: > >> > >> it would be nice if we could write an async version of this, as in > ``async > >> for chunk in aiter(...)``. > > > > The time machine seems to have taken care of this: > > > > > https://docs.python.org/3.6/reference/compound_stmts.html#the-async-for-statement > > > He's asking for an async version of the 'iter' builtin, presumably > something like: > > async def aiter(async_callable, sentinel): > while True: > value = await async_callable() > if value == sentinel: > break > yield value > > -n > > -- > Nathaniel J. Smith -- https://vorpus.org > ___ > Python-ideas mailing list > python...@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] Replacing Infinite while Loops with an Iterator: async edition
On Sat, Jun 23, 2018 at 5:58 PM, Greg Ewing wrote: > j...@math.brown.edu wrote: >> >> it would be nice if we could write an async version of this, as in ``async >> for chunk in aiter(...)``. > > The time machine seems to have taken care of this: > > https://docs.python.org/3.6/reference/compound_stmts.html#the-async-for-statement He's asking for an async version of the 'iter' builtin, presumably something like: async def aiter(async_callable, sentinel): while True: value = await async_callable() if value == sentinel: break yield value -n -- Nathaniel J. Smith -- https://vorpus.org ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] Replacing Infinite while Loops with an Iterator: async edition
j...@math.brown.edu wrote: it would be nice if we could write an async version of this, as in ``async for chunk in aiter(...)``. The time machine seems to have taken care of this: https://docs.python.org/3.6/reference/compound_stmts.html#the-async-for-statement -- Greg ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/