tabs do WHAT?

Thomas Wouters thomas at xs4all.net
Mon Jan 31 09:33:29 EST 2000


On Fri, Jan 28, 2000 at 03:00:03PM +0000, David Maslen wrote:

> However, not everyone uses emacs. As an emacs user I wouldn't wish it
> on you for all it's virtues. I think the python form of indenting
> might be rather annoying if it weren't for the programing tool I
> use.

Actually, most text-editors I know under UNIX, all but Pico (which
braindead, linewrapping, rotting carcass is a 'nono' in any case) do their
indenting fine. My personal poison is Joe, which is a versatile, fast,
intuitive and non-bloated editor with wordstar-based commands (but, of
course, configurable.) It uses filenameglobs to set initial modes on
auto-indent, wordwrap and the like, but it's all easily configurable using
simple keystrokes.

And though actual tab-size is configurable, a tab stays a tab. Just using a
real tab (worth 8 spaces) saves a lot of trouble, since the interpreter also
considers it 8 spaces. To quote Linus Torvalds:

"""
Tabs are 8 characters, and thus indentations are also 8 characters. 
There are heretic movements that try to make indentations 4 (or even 2!)
characters deep, and that is akin to trying to define the value of PI to
be 3. 

Rationale: The whole idea behind indentation is to clearly define where
a block of control starts and ends.  Especially when you've been looking
at your screen for 20 straight hours, you'll find it a lot easier to see
how the indentation works if you have large indentations. 

Now, some people will claim that having 8-character indentations makes
the code move too far to the right, and makes it hard to read on a
80-character terminal screen.  The answer to that is that if you need
more than 3 levels of indentation, you're screwed anyway, and should fix
your program.
""" (CodingStyle, linux kernel source, linux/Documentation/CodingStyle)

With Python you can go a bit farther than 3 levels of indentation and still
keep it readable, thanks to the lack of visible block delimiters ;) but it's
generally good advice anyway. 

Indentation is the first item Linus addresses in his CodingStyle document...
Perversely, the second is block delimiter placement, and he spends a lot
more time explaining his guidelines in that ;)

Use-python--saves-pain-ly y'rs,
-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list