Iterables and Iterators: Going Loopy With Python
summary
Covers Python 2.2→3 iteration protocol with concrete code: getitem fallback vs __iter__/__next__, live IPython notebook and GitHub repo show a Stars class, a character-repeat iterator and generator-based iterable, plus nested-loop demos that reveal exhausted-iterator pitfalls. Demonstrates how generator functions return iterators, how iterables produce new iterators each call, and examples of mutating an underlying container during iteration. Runs ~25 minutes and the code executes as shown.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 4:05What is iteration
- 8:42Old vs new protocols
- 11:15Iterables vs iterators
- 15:54Nested loop pitfalls
- 20:15Key differences
- 24:16Custom iterators
- 27:25Generators and generator functions
- 31:22Generator methods
- 34:33Strings as iterables
- 35:14Summary & Q&A
related talks
25mLazy Looping: The Next Iteration
29mPythonic iterators and generators
02mTutorial Sneak Peek: "Lazy Looping in Practice..."
03mReimplement `itertools` for fun & profit
28mLoop better: a deeper look at iteration in Python
32mIterating Efficiently in Python with itertools
27m"Snakes & Ladders: A Gentle Introduction to Generators and Iterators"
02h 28mFunctional Python
