"for" with "else"?

Stephen Horne $$$$$$$$$$$$$$$$$ at $$$$$$$$$$$$$$$$$$$$.co.uk
Tue Sep 30 21:10:05 EDT 2003


On Thu, 25 Sep 2003 11:15:51 -0400, "John Roth"
<newsgroups at jhrothjr.com> wrote:

>Frankly, I'd like to see special case syntax for an empty
>sequence, but it's not that hard to handle now.

That is what the 'else' suggests to me - particularly with 'while'
loops. I don't think I've ever needed the existing 'else', but I could
have used a loop-body-not-executed-at-all special case on a number of
occasions

I can see the use an application of 'else', of course - if you use
'break' to end a loop you may need different cleanup and therefore
need to skip the standard cleanup. But if this is an issue I'm
probably already using raise rather than break because it's most
likely an error rather than a normal case.

My guess is that it probably made a lot more sense before exceptions
were added to Python.


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list