for what are for/while else clauses

David C. Fox davidcfox at post.harvard.edu
Fri Nov 14 19:47:47 CET 2003


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.

David





More information about the Python-list mailing list