[Python-Dev] PEP 492: async/await in Python; version 4 (original) (raw)
Ethan Furman ethan at stoneleaf.us
Fri May 1 21:19:37 CEST 2015
- Previous message (by thread): [Python-Dev] PEP 492: async/await in Python; version 4
- Next message (by thread): [Python-Dev] PEP 492: async/await in Python; version 4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 05/01, Stefan Behnel wrote:
Yury Selivanov schrieb am 01.05.2015 um 20:52:
I don't like the idea of combining next and anext. In this case explicit is better than implicit. next returning coroutines is a perfectly normal thing for a normal 'for' loop (it wouldn't to anything with them), whereas 'async for' will interpret that differently, and will try to await those coroutines. 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.
--
Ethan
- Previous message (by thread): [Python-Dev] PEP 492: async/await in Python; version 4
- Next message (by thread): [Python-Dev] PEP 492: async/await in Python; version 4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]