why no "do : until"?
peter at engcorp.com
Sun Dec 31 16:05:49 CET 2000
Kragen Sitaker wrote:
> 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).
I can see your point (remarkable, given this thread, isn't it? :-). I
guess I consider the "block" to be everything except the code that allows
entry into the block. Within the block I might have multiple exit
conditions, each shown as separate "if/break" blocks, which are themselves
indented appropriately (and with Python, necessarily!).
But I can't argue with another view on this. After all, in C I've been
using "brace indentation style 3" for the longest time, in apparent
violation of 98% of coding conventions in the world. That is, my braces
are vertically aligned but indented with respect to the "if ()" or "for
()" which gets me into the block:
T = f();
if (T < 25)
Use of that convention is probably what has made me quite happy with
Python's indentation style, which essentially matches this pattern.
More information about the Python-list