[Python-Dev] Re: anonymous blocks

Brett C. bac at OCF.Berkeley.EDU
Thu Apr 28 01:56:33 CEST 2005

Nick Coghlan wrote:
> Brett C. wrote:
>> And while the thought is in my head, I think block statements should
>> be viewed
>> less as a tweaked version of a 'for' loop and more as an extension to
>> generators that happens to be very handy for resource management (while
>> allowing iterators to come over and play on the new swing set as
>> well).  I
>> think if you take that view then the argument that they are too
>> similar to
>> 'for' loops loses some luster (although I doubt Nick is going to be
>> buy this  =) .
> I'm surprisingly close to agreeing with you, actually. I've worked out
> that it isn't the looping that I object to, it's the inability to get
> out of the loop without exhausting the entire iterator.

'break' isn't' enough for you as laid out by the proposal?  The raising of
StopIteration, which is what 'break' does according to the standard, should be
enough to stop the loop without exhausting things.  Same way you stop a 'for'
loop from executing entirely.


More information about the Python-Dev mailing list