On Fri, Apr 24, 2015 at 11:03 AM, Ethan Furman <et...@stoneleaf.us> wrote:
> On 04/24, Yury Selivanov wrote: > > On 2015-04-24 1:03 PM, Guido van Rossum wrote: > > >> Ditto for `__aiter__` and `__anext__`. I guess this means that the async > >> equivalent to obtaining an iterator through `it = iter(xs)` followed by > >> `for x over it` will have to look like `ait = await aiter(xs)` followed > by > >> `for x over ait`, where an iterator is required to have an `__aiter__` > >> method that's an async function and returns self immediately. But what > if > >> you left out the `await` from the first call? I.e. can this work? > >> ``` > >> ait = aiter(xs) > >> async for x in ait: > >> print(x) > > > > With the current semantics that PEP 492 proposes, "await" > > for "aiter()" is mandatory. > > > > You have to write > > > > ait = await aiter(xs) > > async for x in ait: > > print(c) > > As a new user to asyncio and this type of programming in general, 'await > aiter' > feels terribly redundant. > Yeah, but normally you would never do that. You'd just use `async for x in xs`. I'm just bickering over the exact expansion of that. -- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com