Mรณdulo 27 ยท Design Patterns (All 23 GoF) โ Lecciรณn 16 de 23 ยท ~6 min
Iterator
Step through a collection without exposing its guts
Iterator lets you traverse a collection's elements without revealing how it stores them. This is the pattern most fully absorbed into the language: Python's for loop is the iterator protocol. You define __iter__ (often as a generator) and the whole ecosystem โ for, list(), sum(), unpacking โ just works.
A Calendar of bookings can decide its own order and yield entries; callers never touch the internal list.