Message13980
Logged In: YES
user_id=366566
the __iter__ method is supposed to return an object that
defines a 'next' method. The returned object is the one
used for iteration, not the original. So I believe the
error message is correct - Test does not support iteration.
If you change the code to:
>>> class test:
... def __iter__(self):
... return self
... def next(self):
... raise IOError
...
>>> reduce(operator.add, test())
You get the expected result...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 5, in next
IOError
|
|
Date |
User |
Action |
Args |
2007-08-23 14:09:56 | admin | link | issue665761 messages |
2007-08-23 14:09:56 | admin | create | |
|