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

Josiah Carlson josiah.carlson at gmail.com
Sun Apr 26 07:22:52 CEST 2009

On Sat, Apr 25, 2009 at 8:39 PM, Larry Hastings <larry at hastings.org> wrote:
> 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.

FYI, this was proposed a few months ago (see the first post here:
).  I was and still am -1 on any variant of "continue if <condition>"
or "break if <condition>" for the same reasons I was then.  They are a
slippery slope (why not "(raise Exception) if <condition>"?), and they
hide the control flow to the left of the line where we are used to
seeing it on the right side of the line.

 - Josiah

More information about the Python-ideas mailing list