[Python-Dev] Wishlist: dowhile

Guido van Rossum gvanrossum at gmail.com
Mon Jun 13 18:36:07 CEST 2005


On 6/13/05, BJörn Lindqvist <bjourne at gmail.com> wrote:
> do:
>     <block>
> until <cond>
> 
> Written like this it is not very obvious that the 'unil' is part of
> the do-until suite. I also imagine it to be difficult to parse and it
> breaks the rule that suites end when there is a dedentation. So, IMHO
> using an indented 'until' is the least evil of a number of evils.

Not difficult to parse at all, nor un-Pythonic. Multi-part blocks
abound in Python: if / elif / else, try / finally, etc.

> > Why are you so excited about having until indented? You didn't give
> > any examples with multiple occurrences. A single occurrence works just
> > fine unindented, as PEP 315 has already shown.
> >
> > The indented until sounds like unnecessary syntactic sugar for 'if X:
> > break' -- not very Pythonic.
> 
> Yes, but grepping the stdlib produces over 300 hits for "while 1:" and
> "while True:" combined. Some of those a "if <cond>: break" in the
> middle and some would be better written as generators, but lots of
> them would be rewritten as do-while's. So I think there is more than
> enough use cases for syntactic sugar for do-while loops.

The PEP 315 solution looks much better than an "until" that isn't what
it looks like.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list