The Incredible Growth of Python (stackoverflow.blog)

Stephan Houben stephanh42 at gmail.com.invalid
Sun Sep 10 06:21:58 EDT 2017


Op 2017-09-10, Chris Angelico schreef <rosuav at gmail.com>:
> Want to make something iterable? Define __iter__. Want to make it
> async-iterable (with "async for")? Define __aiter__. It's a bit clunky
> if you want the same object to be iterable both ways, but I don't know
> of any real-world situations where that's the case.

Would we not eventually want a file object to deliver its lines
asynchronously (with non-blocking reads under the hood) if
iterated over with "async for", while preserving the current
blocking behavior in the "for" case?

Stephan



More information about the Python-list mailing list