[Python-ideas] for/else syntax

Masklinn masklinn at masklinn.net
Sat Oct 3 19:13:49 CEST 2009

On 3 Oct 2009, at 18:19 , Ron Adam wrote:
> Yuvgoog Greenle wrote:
>> Document it as much as you want but the "else" doesn't hint or clue  
>> as
>> to whether it catches breaks or is skipped by them.
>> The next problem's gonna be at midnight when you're reading code and
>> asking yourself "hmmm, for, blah blah, else, hmm oh yeah, else-break,
>> so this else occurs whenever there's a break."
> True, and that is part of the other 20% I expect the documentation  
> would't help.
> The only solution to that that I can think of is to change the  
> esle's in for and while loops to for/then and while/then in Python  
> 5.0.

That would yield

     for val in vals:
         if cond(val):
         # processing
         # more stuff

how does it make the "alternate" clause being skipped in case of break  
any clearer?

More information about the Python-ideas mailing list