Skip to main content
Loading page…
Python Mastery
Chapter 16
Lesson 3 of 4
Generators & yield
Contents
Notes
Tutor
Concept
How Generators Work
Loading activity…
Previous
1 / 7
Continue
Contents
Notes
Discussion
Tutor
26 min
7 activities
0 of 7 done
In this lesson
1
How Generators Work
2
Generating Infinite Sequences
3
yield from — Delegating to Sub-generators
4
Check: Generator Expression vs. List Comprehension
5
Generators Are One-Shot — Plan Accordingly
6
Practice: Reading a Large Log File in Chunks
7
Explain Lazy Evaluation
Objectives
Write a generator function using yield and explain how execution is suspended
Create a generator expression and compare it to a list comprehension
Use generators to process large or infinite sequences without loading data into memory
Compose generators with yield from
Chapter 16 · Iterators, Generators & Comprehensions
Comprehensions
Iterables & Iterators
Generators & yield
itertools, map, filter
Previous: Iterables & Iterators
Next: itertools, map, filter