[Python-Dev] PEP 492 vs. PEP 3152, new round (original) (raw)
Ethan Furman ethan at stoneleaf.us
Fri Apr 24 20:03:14 CEST 2015
- Previous message (by thread): [Python-Dev] PEP 492 vs. PEP 3152, new round
- Next message (by thread): [Python-Dev] PEP 492 vs. PEP 3152, new round
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 throughit = iter(xs)
followed byfor x over it
will have to look likeait = await aiter(xs)
followed byfor 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 theawait
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.
--
Ethan
- Previous message (by thread): [Python-Dev] PEP 492 vs. PEP 3152, new round
- Next message (by thread): [Python-Dev] PEP 492 vs. PEP 3152, new round
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]