| id | behavioral/iterator | ||||
|---|---|---|---|---|---|
| name | Iterator | ||||
| aliases |
|
||||
| guide_url | https://python-patterns.guide/gang-of-four/iterator/ | ||||
| problem | Traverse a container's elements without exposing how the container stores them. | ||||
| symptoms |
|
||||
| verdict | pythonic | ||||
| caveats |
|
||||
| stdlib_sightings |
|
Traverse elements without exposing storage — lazily when it matters. Verdict: pythonic — the pattern is the language; write generators.
| Where | What |
|---|---|
pattern/ |
The importable code: iterate_pages — chunked traversal behind one generator |
docs/ |
Fundamentals · Implementation guide · External examples |
examples/paginated_client/ |
Mini-project: observably lazy article API client built on pattern/ |
tests/ |
Behavioral tests for the pattern and the mini-project |
uv run python -m patterns.behavioral.iterator.examples.paginated_client.main