Skip to content
masterclass Buddy

Python · Concept

yield

A yield expression turns a function into a generator function. It pauses execution, returns a value, and later continues with preserved local state.

Last updated

Since
2.5

Syntax

yield_expression ::= "yield" expression_list | yield_from

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • generator functions
  • next()
  • send()
  • throw()
  • close()
  • StopIteration
  • GeneratorExit

Source: 6. Expressions — Python 3.11.18 documentation. Checked 2026-11-03.