Python indentation

Steve Lamb grey at despair.dmiyu.org
Wed Jul 7 19:01:12 EDT 2004


On 2004-07-07, Dan Bishop <danb_83 at yahoo.com> wrote:
> The style I use writes it as:
>
>    if (condition) {
>       doThis();
>       doThat();
>    } else {
>       doWhatever();
>       andSoOn();
>    }

> which is 7 lines, only 1 more than the Python version.

> But this does demonstrate an advantage of Python: No arguments over
> where to put braces :-)

    Damn skippy.  'round these parts it would look like this:

if (condition) {
    doThis();
    doThat();
}
else {
    doWhatever();
    andSoOn();
}

    8 lines.  But that's because I never understood why anyone would
willingly use the '} else {' construct since the else is ovten obscured.
Keyword opens the block, } ends the block, never put a block open and close on
the same line.


-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
       PGP Key: 8B6E99C5       | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list