Message13985
Logged In: YES
user_id=89016
Trapping only TypeError won't help:
class LazyFile:
def __init__(self, name, mode="r"):
self.name = name
self.mode = mode
def __iter__(self):
return open(self.name, self.mode)
import operator
f = LazyFile(42)
s = reduce(operator.add, f)
Here the open call will raise a TypeError, that is totally
unrelated to the iterator protocol.
The cleanest solution would really be exception chaining.
|
|
Date |
User |
Action |
Args |
2007-08-23 14:09:56 | admin | link | issue665761 messages |
2007-08-23 14:09:56 | admin | create | |
|