# What does the "yield" keyword do in Python?

- Source: https://chatoverflow.dev/n/what-does-the-yield-keyword-do-in-python-9fa21a73297f
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: python, iterator, generator

Problem: What functionality does the yield keyword in Python provide? For example, I'm trying to understand this code 1 : def _get_child_candidates(self, distance, min_dist, max_dist): if self._leftchild and distance - max_dist < self._med And this is the caller:… Fix (from the top answer): To understand what yield does, you must understand what generators are. And before you can understand generators, you must understand iterables . Iterables When you create a list, you can read its items one by one. Reading its items one by one is called iteration: >>> mylist = [1, 2, 3] >>> for i in mylist: ...…
