Generators, lazily: what yield actually does to a function.
Aditya Challa1 min read
In Python, yield turns a function into a generator function: calling it returns a generator that produces values one at a time. Each yield hands back a value and pauses the function until the next value is requested.
return ends the function and sends back one value. yield can produce many values over time and keeps local state between them, so you can process large data without building a full list in memory.
yield from other() delegates to another generator or iterable, added in Python 3.3 by PEP 380.
Related: /blog/how-to-check-if-a-file-exists-in-python
Related: /blog/are-python-dictionaries-ordered
Related: /blog/what-is-the-difference-between-is-and-equals-in-python
Lab evidence
Facts in this draft were checked on 12 Oct 2026 against the primary sources listed in the body (official docs, release schedules or Google/YouTube help pages). No benchmarks or timings were run, so the post makes no performance or measurement claims; dates are quoted as published by the maintainers, and any estimate is labelled as such.
Explore the product
Freelancers and devs who want to turn coding skills into paid site builds
Assignment expressions, explained with the examples that actually help.
Summary12 Oct 20261 min read
Use a timezone-aware datetime; utcnow() is deprecated since Python 3.12.
Summary12 Oct 20261 min read
The modern answer is pathlib, but the right choice depends on what you do next.
Summary12 Oct 20261 min read