3 ms·
Check any tutorial about it or even the relevant pep. It's explained in many places. In short: def some_co(): yield 2 yield 3
by viraptor 11y ago
Check any tutorial about it or even the relevant pep. It's explained in many places. In short:
def some_co():
yield 2
yield 3
- dkarapetyan 11y agoHmm, It is a SyntaxError to have yield or yield from expressions in an async function. That's what I mean when I say it misses the mark. There are now two ways of doing the same thing and one of them is more powerful than the other. Using generators I can use both `yield` and `yield from` but if I use what they're calling co-routines then I can only use `yield from`. I see no value in the new syntax. So an async function is not really a co-routine. It is a regular function that gets to use `await` and that's it. Calling it a co-routine is misleading and confusing.