Vladimir

57%
Flag icon
Whenever Python needs to iterate over an object x, it automatically calls iter(x). The iter built-in function: Checks whether the object implements __iter__, and calls that to obtain an iterator. If __iter__ is not implemented, but __getitem__ is, then iter() creates an iterator that tries to fetch items by index, starting from 0 (zero). If that fails, Python raises TypeError, usually saying 'C' object is not iterable, where C is the class of the target object.
Fluent Python: Clear, Concise, and Effective Programming
Rate this book
Clear rating
Open Preview