Tabs and spaces (style)

Cantanker az at
Tue May 1 22:37:24 EDT 2001

Kenneth Loafman <ken at> wrote:

> I'm just the opposite... why would anyone use tabs?  All a tab does is
> screw up the alignment for anyone that has a different tab size set and
> makes it very difficult to print, etc.

How so? If everyone uses tabs exclusively, it wouldn't matter whether I
set my editor to display (or print filter to print) tab characters at
2,4,8 or 16 spaces, because anyone else can edit my file and have his or
her editor set to any other possible tab size, and _ALL_ the code will
line up properly. If, however, everyone uses spaces exlusively, one
author's (or the language author's *cough*) choice of _indent_ size is
imposed on everyone else. And I like to switch between 2,4 and 8 space
tabs (sometimes 6) just so the code _looks_ nice to me at that point and
I feel more comfortable editing it. But obviously this is better than
mixing tabs and spaces, as everyone seems to think.

Alex Martelli <aleaxit at> wrote:

> I don't think there is one.  Guido's style guide recommends using both,
> with a tabsize of 8, so I expect most Pythonistas follow that style. 
> Yet, for what it counts, I personally prefer setting my editors to
> always save with spaces only (so _all_ tools will certainly see my
> source in just the same way:-) and curse every time somebody posts code
> using tabs (which some newsreading software hides completely from me)...

Of course, when writing text which is to be _viewed_ (email, news,
READMEs), I always use ':set et' which expands tabs to spaces, but for
text to be _edited_ by others you would use tabs, for the reasons above.

But thanks for such insightful replies. I had forgotten Guido's style
guide existed, and thanks for pointing me to :)

PS. wrt printing, mpage is a really cool utility. Here are some of 
the options I use for printing text:

    mpage -s4 -W100 -L80

More information about the Python-list mailing list