The Startup
Published in

The Startup

What is “yield” or “generator” in Python?

What is a “coroutine” in Python?

A lot of new python learners have a hard time wrapping their brain around PEP 380. I am usually asked:

  1. What does the “yield” keyword do?
  2. What are the situations where “yield from” is useful?
  3. What is the classic use case?

--

--

--

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +756K followers.

Recommended from Medium

The magical world of containers — benefits

AWS Glacier- Data Retrievals Made Easier

Tutorial: How to Join the HALO Community to Earn Passive HO Rewards (MetaMask Desktop Version)

Bringing High-quality Imaging to the Web Platform

How to reduce NodeJS Docker Image Size?

Unity-Solana Wallet Updated With NFT Support

Think Globally, Sponsor Locally

Visual Testing & Tools

Cover Image of the Story

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Harshal Parekh

Harshal Parekh

More from Medium

Sending iMessages with Python on a Mac

How to Send automated Slack Notifications with Python — The Easy Way

How to Convert Maya Python 2 Code to Python 3

Using Python to generate an Anki deck