PEP 315: Enhanced While Loop

Alex Martelli aleax at aleax.it
Mon May 5 16:14:01 EDT 2003


W Isaac Carroll wrote:
   ...
> 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

No more than you could with the current way of spelling it:

      while <cond1>:
          <block1>
          if not <cond2>:break
          <block2>

if you're scrolled so the END of the while's body is not showing, then
you know there MIGHT be exist conditions further down -- nothing new.

The issue with the original proposal's "do ... while cond>" is that you
might have been looking right at the "while cond:" clause AND have no
way to now you should be looking BACKWARDS for a crucial part of the
loop -- THAT would have been a novel trap.  But there is nothing like
that in this proposal.


Alex





More information about the Python-list mailing list