What Are Python Coroutines?

Give Feedback

This lesson and the subsequent ones introduce Python coroutines and the benefits of running things asynchronously. You’ll learn what they are and how they compare to generators.

In this video, you’ll also see how to create a synchronous function that prints out a random number after a few seconds.

def randn():
    time.sleep(3)
    return randint(1, 10)

Comments & Discussion

UBBA on May 16, 2019

Note that iPython is now Jupyter. %time will work in Jupyter which can be run right inside Visual Studio Code(Run python in interactive window).

Become a Member to join the conversation.