Why Python style guide (PEP-8) says 4 space indents instead of 8 space??? 8 space indents ever ok??

Steve Lamb grey at despair.dmiyu.org
Thu Oct 23 03:07:28 EDT 2003


On 2003-10-23, Christian Seberino <seberino at spawar.navy.mil> wrote:
> Each has trade offs.... I don't like breaking last line into 2 pieces
> but at least "class", "def", "for" and "if" don't blend into each
> other as easily as in the 2nd example.

    They blend in?  How so?  8 spaces is way too far for the eyes, or at least
*my* eyes, to skip without causing serious pauses.  2 spaces, while I use it
immensely in my Perl days, is where blending occurs.  4 spaces it's pretty
clear that the next line down is a separate block while not having to jump
partway to Siberia to indicate it.  Furthremore at 4 spaces you have a
continuation of the lines above to the lines below in even the shortest of
lines.

if x:
    x = y
elsif y:
    y = z
else z:
    z = x

vs.

if x:
        x = y
elsif y:
        y = z
else:
        z = x

    Notice that on the 2nd example the block isn't under the control
statements at all.  There's no relation of those blocks to the statements
above it.  To me that is the biggest thing.  There's separation but not so
much that there isn't flow.

if x:
1234v

else:
1234v

    Of course, this is all personal preference.  You want 8, have fun.  :P

--
         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