7 Feb
2014
7 Feb
'14
4:15 a.m.
On 2/6/2014 9:45 PM, Chris Angelico wrote:
On Fri, Feb 7, 2014 at 1:36 PM, Terry Reedy
wrote:
def __next__(self): try: x = self.func() except Exception as exc: if isinstance(exc, self.sentinel): raise StopIteration from None else: raise if x == self.sentinel: raise StopIteration else: return x
Forgive me if this is a stupid question, but wouldn't this suppress any other thrown exception? I'm looking for a bare 'raise' inside the except block,
which should be there. As I said, but you snipped, '(untested)'
such that any exception is guaranteed to raise something, but if it's a subclass of self.sentinel, it raises StopIteration instead.
-- Terry Jan Reedy