20 Mar
2009
20 Mar
'09
6:35 p.m.
Jacob Holm wrote:
The "GeneratorExit", I expect due to the description of close in PEP 342:
def close(self): try: self.throw(GeneratorExit) except (GeneratorExit, StopIteration): pass else: raise RuntimeError("generator ignored GeneratorExit")
Hmmm... well, my PEP kind of supersedes that when a yield-from is in effect, because it specifies that the subiterator is finalized first by attempting to call its 'close' method, not by throwing GeneratorExit into it. After that, GeneratorExit is used to finalize the delegating generator. The reasoning is that GeneratorExit is an implementation detail of generators, not something iterators in general should be expected to deal with. -- Greg