Build a Data Pipeline
Advanced · Write the code · from Python Generators: Process Millions of Items Without Running Out of Memory
From the lesson: How Do You Build a Generator Pipeline?
One of the most powerful patterns with generators is pipelining - chaining multiple generators together, where each one processes data from the previous one. Think of it as an assembly line: each station does one small transformation.
Read this part of the lessonBuild a three-stage generator pipeline:
1. words(sentence) - yields each word from the sentence (split by spaces)
2. long_words(seq, min_len) - yields only words with length >= min_len
3. uppercased(seq) - yields each word in uppercase
Then chain them: uppercased(long_words(words(sentence), 4))
Use the sentence: 'the quick brown fox jumps over the lazy dog'
More Generator exercises
- Your First GeneratorIntermediate
- Predict the Generator OutputIntermediate
- Refactor to a GeneratorIntermediate
- Flatten with yield fromAdvanced
- Fix the Generator BugAdvanced
- Infinite Fibonacci GeneratorAdvanced
All Python exercises · 50 practice problems · Advanced Python quiz