PEP 315: Enhanced While Loop

W Isaac Carroll icarroll at pobox.com
Mon May 5 15:25:22 EDT 2003


Alex Martelli wrote:
> I do agree the outdents make the structure clearer -- indeed, that's
> essentially THE point.  I think this proposal should go in the PEP --
> it does not suffer disadvantages such as new keyword introduction.

Yes. That is one of the fundamental ideas that I'm shooting for. The 
loop condition needs to be clearly visible so the loop's behavior is 
clearly understood.

As long as the syntax makes the loop clear the exact spelling doesn't 
matter much. I like the "and while" syntax well enough, and it seems to 
be an acceptable compromise between clarity and not breaking compatibility.

The only thing that concerns me about the generalized case

     while <cond1>:
         <block1>
     and while <cond2>:
         <block2>

is that it has the same problem as was brought up about the do-while 
syntax: When a part of the loop is off the screen or on another page, 
you might get the wrong idea about the loop. However, if you see 
"while:" you know something funny is going on and you can pay closer 
attention.

TTFN






More information about the Python-list mailing list