why no "do : until"?

Kragen Sitaker kragen at dnaco.net
Sun Dec 31 14:03:25 CET 2000


In article <3A4EC5B1.8912E571 at engcorp.com>,
Peter Hansen  <peter at engcorp.com> wrote:
>Kragen Sitaker wrote:
>> 
>> The only time I wish I wasn't subject to Python's indentation rules is
>> when I can't outdent my "if finished(): break" statements like I do in
>> C.
>
>But why would you want to outdent it?  It's *part* of the loop, not a
>following statement.  Identation should match the block structure of the
>code, and that statement lies _within_ the block.

I would want to outdent it because, in my view, it isn't part of the
loop body; it's part of the loop structure itself, just like the while
1: at the beginning.  It is not within the block of code controlled by
the loop.  In fact, it comes *between* two blocks of code controlled by
the loop, much as else: comes between two blocks of code controlled by
an if (or, in Python, a for or while).

Indenting it with the rest of the code makes it appear as if there is
only one block of code, when in fact there are two basic blocks that
will run different numbers of times.
-- 
<kragen at pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we possess
ourselves.
       -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI]





More information about the Python-list mailing list