[Python-Dev] Wishlist: dowhile
Charles Cazabon
python at discworld.dyndns.org
Wed Jun 15 21:03:52 CEST 2005
Nicolas Fleury <nidoizo at yahoo.com> wrote:
> Guido van Rossum wrote:
> > 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.
>
> FWIW, I must say I disagree (about "works just fine"). I find PEP 315
> counter-intuitive. There's multi-part blocks in Python, but they all
> behave like a step-sequence where you never come back to a previous
> step. What I mean is that after entering a finally/except/elif/else,
> there's no coming back in the try/if/for/while. My first impression
> when looking at:
>
> do:
> <block1>
> while condition:
> <block2>
>
> is that <block1> is executed only once.
Indeed. The original poster seems to want something that would work (not
necessarily look) like this:
do:
<block>
while <condition>
with <block> executed once prior to <condition> first being tested. But the
above is ugly, and you can get much the same effect with Python today:
firsttime = True
while firsttime or <condition>:
<block>
firsttime = False
Seems fairly Pythonic to me. YMMV.
Charles
--
-----------------------------------------------------------------------
Charles Cazabon <python at discworld.dyndns.org>
GPL'ed software available at: http://pyropus.ca/software/
-----------------------------------------------------------------------
More information about the Python-Dev
mailing list