Geek Culture
Published in

Geek Culture

Understand Python “yield”, An interrupt, A trap, A scissor

Some said “yield” is similar to the usage of “return”, the answer could be both yes and no. But one thing is certain: yield is not return.

What is yield in Python?

The keyword “yield” working like a scissor cut the program into two parts.

The keyword “yield” working like an interrupt in OS, yield will return the control of the program back to the caller.

The keyword “yield” not only gives control back to the caller, but it can also…




A new tech publication by Start it up (

Recommended from Medium

Which accessibility testing tool should you use?

How to Fix Can't assign requested address: Service 'sparkDriver' failed after 16 retries

The Rise of Carve 2.0

Tidying Up with Wealthsimple

Kubernetes for dummies by a dummy

Speed is the New Currency — Digital Transformation

Someone who writes source code in one or more programming languages in order to develop and build…

The Turing Machine Halting Problem

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
Andrew Zhu

Andrew Zhu

Data Scientist @ Microsoft | | | Programmer | Python | Science | History

More from Medium

Escape Python’s GIL with Numpy

Lightweight and Efficient Database Alternatives For Python

The Most Useful Python Modules You Should Know

Python’s Secret Module: Secrets