Skip to main content
Loading page…
Python Mastery
Chapter 16
Lesson 2 of 4
Iterables & Iterators
Contents
Notes
Tutor
Concept
Iterable vs. Iterator
Loading activity…
Previous
1 / 7
Continue
Contents
Notes
Discussion
Tutor
22 min
7 activities
0 of 7 done
In this lesson
1
Iterable vs. Iterator
2
Probing the Iterator Protocol by Hand
3
Building a Custom Iterator
4
Check: What Does iter() Return?
5
Iterator Protocol Deep Check
6
Don't Call next() on a Bare Iterable
7
Practice: Custom Fibonacci Iterator
Objectives
Explain the difference between an iterable and an iterator
Manually drive iteration with iter() and next()
Describe what a for-loop does under the hood in terms of the iterator protocol
Implement a custom iterator class with __iter__ and __next__
Chapter 16 · Iterators, Generators & Comprehensions
Comprehensions
Iterables & Iterators
Generators & yield
itertools, map, filter
Previous: Comprehensions
Next: Generators & yield