[Python-ideas] Replacing Infinite while Loops with an Iterator: async edition
Nathaniel Smith
njs at pobox.com
Sat Jun 23 21:11:31 EDT 2018
On Sat, Jun 23, 2018 at 5:58 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> jab at 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
More information about the Python-ideas
mailing list