John Roth wrote: > > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> Currently the else block in a for loop gets executed if the loop is >> completed, which seems backwards to me. I would expect the else to >> complete if the loop was broken out of. That seems more constant with >> if's else block executing when if's condition is false. > > > Actually, it makes sense if you look at it correctly. > > In an unadorned loop, exits via break and via the > loop condition becoming false go to the same place. > To distinguish requires some kind of a switch. > > In a loop with an else, exits via break skip the else > clause, while an exit via the loop condition takes > the else clause. You don't need a special exit on > break since you can put any amount of logic after > the if and in front of the break. Where you need it > is on exit via the loop condition. > > The difficulty you're having with this is that else > is a very bad keyword for this particular construct. > I'd prefer something like "on normal exit" as > a keyword.
It's not a difficulty. This is the point I was making. :) My suggestion is to use, also as the keyword to mean "on normal exit" 'also' do this. Ron -- http://mail.python.org/mailman/listinfo/python-list