Python indentation

Alan Gauld alan.gauld at btinternet.com
Thu Jul 8 11:20:56 CEST 2004


On 07 Jul 2004 19:50:03 -0400, David Bolen <db3l at fitlinxx.com>
wrote:

> Clearly it's an "in the eye of the beholder" thing.  I will admit to
> being a K&R "one true brace style" guy.  

Actually its not just an "eye of the beholder thing". McConnell
discusses this in his Code Complete book and cites studies that
showed that the style that most programmers preferred was not the
style that led to best comprehension.

As a result of that I changed my C style from

if (foo)
{
   doit()
}
else
{
   doAnother()
}

Which had been the preferred style in McConnels reference study
To

if (foo) {
  doit()
  }
else {
  doAnother()
  }

Then I changed my "style" even more radically to:

if foo:
   do it()
else:
   doAnother

Both of which matched McConnels best practice, but the Python one
gave me no cosmetics versus comprehension debate... :-)

Alan G.

Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Python-list mailing list