[Python-Dev] Wishlist: dowhile

Raymond Hettinger raymond.hettinger at verizon.net
Mon Jun 13 03:57:22 CEST 2005


More than case-statement semantics or PEP343, I wish for a dowhile
statement.

The most straight-forward way is to put the conditional expression at
the beginning of the block with the understanding that a dowhile keyword
will evaluate the condition only after the block runs:

    dowhile <cond>:
        <body>

being the equivalent of;

    _firstpass = True
    while _firstpass or <cond>:
        _firstpass = False
        <body>


Raymond



More information about the Python-Dev mailing list