How to make coroutines return values.
WHY
Maybe you need to handle a large volume of records and you heard coroutines are a good way of doing it. Or maybe you just started looking into them. Whatever the reason, you probably have noticed that a lot of blog posts and tutorials out there show how to code one to print some values.
If you then tried to actually do something with them, you may have ended up here trying to figure out how to coerce the little buggers into returning those values!
You are not alone 😉 I too found it confusing to figure out at first. So I'm going to show you the basics of how to use python coroutines that return values.
If you're in a hurry, let me give you the secret sauce up front: define your yield-expression with a variable! That's all, simple but often overlooked.
For a complete explanation, examples, and walls of text please read on 🙂
