> Somewhat unusually, our syntax uses yield rather than await, but the behaviour is the same. Await another coroutine with yield coro. Await on multiple with yield [coro1, coro2, ...] (a 'gather' in asyncio terminology; a 'nursery' in trio terminology).
I have a function I want to be a coroutine, but it has zero yield statements, so it is just a normal function?
You can distinguish it from a normal Python function by putting if False: yield somewhere inside its body. Another common trick is to put a yield statement after the final return statement. Bit ugly but oh well.
I'm fairly unfamiliar with python and I don't quite understand what this is actually doing. Does it change anything in the execution or is it just to mark it in a way for IDEs to do something with?
7 comments
[ 2.3 ms ] story [ 24.1 ms ] threadWhy, though?
(Though it's really a pretty tiny library that just does what it says on the tin, not sure how many questions there can be. :D )