12 Dec
2014
12 Dec
'14
8:06 p.m.
On Fri, Dec 12, 2014 at 2:28 PM, Ethan Furman
3) there are essentially two (and a half) ways for python code authors to write their own, custom TIIP: 1) write a class that has a __iter__ and __next__ methods that "do the right thing" 2a) write a generator function 2b) write a generator expression
3) write a class with __getitem__ that supports integer indexing
This gets you a custom iterable. The corresponding iterator will be the buitin iterator type:
class X: ... __getitem__ = None ... iter(X())