Question about indentation and bugs

Peter Hansen peter at engcorp.com
Sun Aug 26 01:01:06 CEST 2001


Paul Winkler wrote:
> 
> On Fri, 24 Aug 2001 01:08:13 -0400, Peter Hansen <peter at engcorp.com> wrote:
> >Maybe more importantly, if you don't actually use TABs,
> >or you consistently treat TABs as eight spaces, the problem
> >won't arise.
> 
> Four spaces is now the "standard" according to PEP 8, replacing the
> old style guide.  http://python.sourceforge.net/peps/pep-0008.html
> 
> But then, the style guide says the same thing... How long ago was 8
> considered the norm?

You miss my point.  A TAB is an ASCII character which should be 
treated as causing the current horizontal position to jump to the
next multiple of eight.  (Yes, there is probably no such specific
definition in any ASCII standard, but I'm talking from a practical
sense here.  The vast majority of computer programs and operating
systems treat TAB this way and using them to mean anything else is
just asking for trouble.  Programs which treat them as precisely
eight characters (regardless of their position) are broken.  
Programs which treat them as four characters are dangerous.)

The point is, if you insist on using TABs in your output in order
to save space (an unnecessary endeavour these days), you should
ensure that you treat them according to the proper definition.
Lines indented four characters from the left margin should use
four spaces (not a TAB).  Lines indented eight characters can 
use a single TAB (not two).  Lines indented twelve characters 
should have four spaces and a TAB (not three TABs).  

TABS: just say no...

I agree indentation should definitely be every four characters.  
I don't think I've ever seen real, non-trivial code which was 
indented eight characters, and I would have reindented it if I had.

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list