Python indentation deters newbies?

Peter Hansen peter at engcorp.com
Mon Aug 16 00:48:10 EDT 2004


Dennis Lee Bieber wrote:

> 	Missed one variant <G>... Since the brackets are, in my mind,
> noise, I prefer to keep /them/ aligned (easiest means of drawing lines
> on a listing...
> 
> if (condition)
> {
> 	stmt-1
> 	stmt-2
> }
> else
> {
> 	stmt-3
> 	stmt-4
> }

Missed another!  (The best! ;-)

if (condition)
     {
     stmt-1;
     stmt-2;
     }
else
     {
     stmt-3;
     stmt-4;
     }

After all, the braces are basically part of the blocks, so they
really should be indented the same as the statements in the
blocks.  Furthermore this way it's easier to scan down to find
the else or subsequent code.  Basically, this way the braces
don't really get in the way at all, except for using up some
vertical space.

-indentation-wars-backwards-r-us-ly y'rs,
  Peter



More information about the Python-list mailing list