In this video, Josh McQuiston gives a high level explanation of python coroutines. He explains how coroutines are a concept that puts a sharp twist on python generators and the yield statement, enabling a different kind of functionality that can enable you to build powerful tools to add to your data processing toolbox.
- Another important tool that we build out…of Python generator is the coroutine.…While a generator is something that produces values…each time it's called, a coroutine is something…you constantly give things to…that may or may not return anything.…Instead, it takes what is passed to it…and does something with it.…What you give it and what it does with it…are completely up to you.…It's important to understand the differences between…coroutines and generators thoroughly…and what they are capable of.…
Unlike generators, coroutines are not…for iterating over sequences.…While technically a coroutine object is a generator object,…these are two concepts that really ought…to be treated separately and not intermixed.…A coroutine is designed to repeatedly send input to it,…process that input by following the logical path…that you program it to follow, and stop…when it reaches the yield statement.…On the surface, that sounds fairly similar…to what a function does…but there are some important differences.…
A function is also a set of logical instructions…
Share this video
Embed this video
Video: Coroutine overview