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

Paul Boddie paul at boddie.net
Mon Dec 3 06:53:55 EST 2001


Courageous <jkraska at san.rr.com> wrote in message news:<0pvl0ug52ug206qkpne2sjrinb2e8qsvam at 4ax.com>...
> 
> I see this in other programming languages all the time, where someone
> comes along with a different tab notion than mine, edits the file, and
> then commits it. This creates horribly formatted files where the
> indentation levels of lines of code throughout the file.

Perhaps you might want to put some kind of processing step into your
revision control procedures or tools. I think I raised this issue
before on comp.lang.python but some people think it's more interesting
to get religious about tabs vs. spaces instead.

Personally, I use tabs for my own code because I have a UNIX
background and the only decent editors available on the systems I used
treated tabs properly. Subsequently, I've had the need to use spaces
for indentation, and decent editors will let you configure this and
even try and make the navigational behaviour workable too - where
editors treat indentation spaces as a collection of characters that
have to be navigated past individually, then the editing experience
starts to get irritating.

As most people are aware, tabs were intended for indentation purposes
in human-readable documents, whereas spaces are just word separators.
As a side-effect of the implementation of spaces, they can also be
used for indentation and text justification, but that doesn't mean
that they should be used for such purposes. Indeed, using spaces in
such a way in word processing or desktop publishing is a habit which
will inevitably get you into trouble, but the unfortunate thing is
that most word processors won't guide the user into avoiding this kind
of mistake. It would be interesting to see word processors accept just
one space between words, for example, as a means of discouragement.

Sadly, we just have to live with spaces in their unintended role, but
I think that rather than wasting time inventing urban legends,
folklore and "reasons" why one is better than the other, we should be
talking about practical measures that projects can use to avoid
tab/space mixing and other text-based nightmares (DOS text vs. UNIX
text, for example).

Paul



More information about the Python-list mailing list