Andrew Breza

57%
Flag icon
If a class provides __getitem__, the iter() built-in accepts an instance of that class as iterable and builds an iterator from the instance. Python’s iteration machinery will call __getitem__ with indexes starting from 0, and will take an IndexError as a signal that there are no more items.
Fluent Python: Clear, Concise, and Effective Programming
Rate this book
Clear rating
Open Preview