[Python-Dev] PEP 492: async/await in Python; version 4

Yury Selivanov yselivanov.ml at gmail.com
Fri May 1 21:24:36 CEST 2015


On 2015-05-01 3:19 PM, Ethan Furman wrote:
>> Sure, but the difference is that one would have called __aiter__() first
>> >and the other __iter__(). Normally, either of the two would not exist, so
>> >using the wrong loop on an object will just fail. However, after we passed
>> >that barrier, we already know that the object that was returned is supposed
>> >to obey to the expected protocol, so it doesn't matter whether we call
>> >__next__() or name it __anext__(), except that the second requires us to
>> >duplicate an existing protocol.
> If we must have __aiter__, then we may as well also have __anext__; besides
> being more consistent, it also allows an object to be both a normol iterator
> and an asynch iterator.

And this is a good point too.

Thanks,
Yury


More information about the Python-Dev mailing list