[Python-ideas] Updating PEP 315: do-while loops

Larry Hastings larry at hastings.org
Sun Apr 26 05:39:05 CEST 2009

Chris Rebert wrote:
> I don't see why the if-as-suffix is needed when we already have a
> one-liner for such situations (e.g.):
> if i != '1': break
> It's much more uniform and only one character longer.

I certainly see your point.  Let me take it a step further: the "do: ... 
while <condition>" construct isn't needed, given that it's already 
expressible with "while True: ... if not <condition>: break".

It's true, "break if <condition>" and "continue if <condition>" are 
redundant constructs.  But this debate is over refining our syntactic 
sugar--charting what is arguably a redundant construct.  Therefore 
proposing redundant constructs for the sake of clarity is on the table.  
I think "break if <condition>" and "continue if <condition>" enhance 
readability; they make the control flow pop out at you more than "if 
<condition>: break" and "if <condition>: continue" do.  "break if" and 
"continue if" have the advantage of following established Python 
syntactic precedent.


More information about the Python-ideas mailing list