Indentation style...

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Sun May 27 15:53:23 EDT 2001


Sun, 27 May 2001 10:52:59 -0700, Ken Peek <Peek at LVCM.comNOSPAM> pisze:

> Python allows the use of spaces or tabs (but not both!) to indent
> with.  I think this was a mistake.  I think tabs should be forced
> at the beginning of lines, and spaces should be forced after the
> first printable character is typed.

There should never be a requirement of using tabs in plain text.
Some people don't use tabs at all, especially as many editors don't
allow convenient indenting when the indent size is different from
the tab size.

> This will allow the programmer to set their editor to display a tab at whatever
> indentation spacing they like,

Setting physical tab size to anything other than 8 characters is
a bad idea. Tabs and spaces will be mixed no matter what we try to
do, and using a consistent tab size allows to define an unambiguous
meaning of such mix.

Indents of 8 chars are usually too big. Many people prefer 2, 3 or 4.
So indents should not be coupled with the tab size.

Note that it's impossible to mix some of your postulates with mine.
If tabs and spaces are mixed, then the tab size should be a constant;
if tabs are 8 characters, then indents should not be necessarily
equal to tabs.

Here is what I recomment (compatible with Python's status quo):
1. Tab size is always 8.
2. Indent with spaces or tabs, but preferably spaces.
3. Indent size is up to the author. I use 4.

If point 1 was rigorously followed, point 2 would not have to recommend
spaces; but some heretics use a different tab size so it's safer to
use spaces.

This works for all languages except Clean which has significant
whitespace and defines the tab size to 4. IMHO this is a big mistake;
perhaps Macintosh origins have something to do with that.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list