Deprecate tabs for indenting (was Re: Indenting with tabs vs spaces)

Delaney, Timothy tdelaney at avaya.com
Wed Dec 12 18:28:48 EST 2001


> From: Ville Vainio [mailto:vvainio at karhu.tp.spt.fi]
> Courageous <jkraska at san.rr.com> writes:
> 
> > But this is all academic, because the defacto and near 
> dejure standard
> > for Python is 4 spaces per indentation level. Tabs are deprecated.
> 
> Why don't issue a DeprecationWarning whenever tabs are found in the
> source file? That wouldn't "break" things, but it would surely
> motivate tab-using people to learn the right way of doing things.

I've kept out of this until now, because I didn't want to add to the flames
...

However, I would be heavily opposed to this. Firstly, it's a tool issue -
the best editor I have found on Windows (i.e. most similar to BBEdit on the
Mac ;) is EditPlus - however, I cannot find a way to force it to delete
multiple spaces (to the previous tab stop) with a single keypress. So I use
hard tabs for indents (and indeed, have *always* used hard tabs on every
platform).

The other main issue is mixing spaces and tabs. There are again two issues
involved - mixing spaces and tabs for indent levels, and mixing spaces and
tabs to line things up.

Spaces and tabs should *never* be mixed up for indent levels.

T   statement
TT      statement
T   SSSSstatement
SSSST   statement

is *bad*

However, using hard tabs for indenting, then spaces for lining things up is
not such a bad thing.

T   statement
TT      callable(param,
TT      SSSSSSSSSparam)

leaves layout perfectly fine, no matter what someone has set their tabstops
to. You may (if you prefer) replace the above tabs with spaces ...

SSSSstatement
SSSSSSSScallable(param,
SSSSSSSSSSSSSSSSSparam)

perfectly well.

The problem as I see it one of retraining. I refuse to retrain myself to
backspace through multiple spaces simply to reduce indentation (although I
would normally use block dedent anyway). I refuse to change from an editor
which in all other ways suits my purposes, since changing to another editor
would involve retraining to get used to its idiosyncracies, and I have not
found an editor in Windows which is a pleasing on the eyes as EditPlus (and
that is a major consideration).

Unix is the only platform which has maintained the "4 space indent, 8 space
tabstop". Macs have always had a four-space-equivalent tabstop as standard
(for text editors and IDEs). Windows has always been a mess.

My solution is to set the tabstop at what it should be (mandated by the
project - in my current project, 3 spaces per tabstop for Java), convert
leading spaces to tabs after checking out a file, convert tabs to spaces
before checking in a file. I wish it were easier, but this works for me.

Tim Delaney




More information about the Python-list mailing list