Priming a Coroutine

Learn how to prime coroutines with decorators.

What is priming?

When a coroutine is created and hasn’t exploited its first send, we use the next method to activate it to advance to its first yield; this is known as priming a coroutine.

Previously, we had been priming the coroutines by explicitly calling the next method in the main section of the code. How about priming a coroutine in a Pythonic way and sound more expert?

Decorators priming a coroutine

Decorators guarantee propitious flexibility when using coroutines. Without any further ado, let’s take hold of this feature.

As an example, we’ll be priming the coroutine maximum that was given to you as a challenge.

Get hands-on with 1400+ tech skills courses.