Non-Indented python

Huaiyu Zhu hzhu at mars.localdomain
Sat Nov 24 12:12:50 CET 2001

On Fri, 23 Nov 2001 17:31:51 +0000 (UTC), Marcin 'Qrczak' Kowalczyk
<qrczak at> wrote: 
>Wed, 21 Nov 2001 23:00:35 -0500, Dave Cinege <dcinege at> pisze:
>> Not so. It's completely logical. A single byte, per indented block
>> instead of some variable, arbitary number.
>This would be a bad idea:
>- using tab width of any other size than 8 is evil,
>- 8 is too much for indentation in programming; 2 to 4 is good.

There are really two issues involved:

If everything can be redesigned from scratch, what would be the best
indentation method for languages like Python's?  There is a strong argument
for one tab character per indent level. When indentation is encoded as the
number of tab charactors, code can be exchanged between different
programmers completely unaffected by the display style.  The editor might
even display it as charactor like this:


In this situation, what's the best distance between tab stops?  If tabs were
used to help reducing key strokes while typing a table on a typewriter, 8
makes most sense, because 8x8=64.  When tab is used to indent programs, the
most active range of indentation would be before the first 16 charactors, so
a tab stop of 4 is more economical in terms of key strokes.  However,
whichever size set in any editor will not mess up the code in any other

The second question is whether it is wise to set tab to a size other than 8
in a world where many utilities expect it to be 8?  I've been setting tab=4
in emacs for several years (before using Python) and there is no adverse
effect, as long as certain precautions are taken:

- set tab size in editor (emacs), pager (less) and formatter (enscript).
- Do not forget tabify the code when space is suspected to have sneaked in.

The only problemd I encountered came code from others which mixes tab with
space.  It rarely happens in my own code, because having different tab size
between emacs and python means such code rarely goes unnoticed.

As to the problem wiht copy-and-paste - one charactor per indent level is
great. When the indent level changes, you just insert or remove a certain
number of tabs to the whole block.


More information about the Python-list mailing list