for what are for/while else clauses

John Roth newsgroups at jhrothjr.com
Fri Nov 14 14:43:58 EST 2003


"David C. Fox" <davidcfox at post.harvard.edu> wrote in message
news:nr9tb.200590$Fm2.189136 at attbi_s04...
> Diez B. Roggisch wrote:
>
> > Hi,
> >
> > today I rummaged through the language spec to see whats in the for ...
else:
> > for me. I was sort of disappointed to learn that the else clauses simply
> > gets executed after the loop-body - regardless of the loop beeing
entered
> > or not.
>
> I didn't realize that for...else existed, but according to the language
> reference, the else clause gets executed unless the loop body exited due
> to a break statement.

Yep. It's one of the three termination conditions for a loop. The problem
is that it's a really bad name, and the termination condition I'm most
interested
in catching is the one where the loop didn't execute at all.

John Roth

>
> David
>






More information about the Python-list mailing list