On Sat, Sep 13, 2003 at 04:18:51PM +0200, Samuele Pedroni wrote:
OTOH conflating 'with' and 'for' just for generators seems a rather ad-hoc breaking of orthoganility of the two, you could not write anymore code like this:
g = gen() for v in g: ... do something up to a point ... ... for v in g: ...
I had thought about this. This occurs when you 'break' out of the first loop. I would say that NOT calling the __exit__() method in this specific case seems quite intuitive, the 'break' meaning 'just exit from the loop now without any further processing, skipping the 'else' part if present'.