iter jitters

Peter Otten __peter__ at web.de
Wed May 5 02:20:52 EDT 2004


Heiko Wundram wrote:

> def __iter__(self):
>     for e in self.data:
>         yield e

Another option:

>>> class Foo:
...     def __init__(self):
...             self.data = range(10)
...     def __iter__(self):
...             return iter(self.data)
...
>>> for i in Foo():
...     print i,
...
0 1 2 3 4 5 6 7 8 9
>>>

Peter




More information about the Python-list mailing list