def__next__(self): """Return the next item from the generator. When exhausted, raise StopIteration. """ returnself.send(None)
@abstractmethod defsend(self, value): """Send a value into the generator. Return next yielded value or raise StopIteration. """ raise StopIteration
@abstractmethod defthrow(self, typ, val=None, tb=None): """Raise an exception in the generator. Return next yielded value or raise StopIteration. """ if val isNone: if tb isNone: raise typ val = typ() if tb isnotNone: val = val.with_traceback(tb) raise val