This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tabs is better than spaces for indentation
Type: enhancement Stage: resolved
Components: None Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: loewis, r.david.murray, rohdef, tim.peters
Priority: low Keywords:

Created on 2009-09-28 12:26 by rohdef, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg93205 - (view) Author: Rohde Fischer (rohdef) Date: 2009-09-28 12:26
Although it's probably futile, I'll still give it a try.

I can see in your tutorial that you desire 4 spaces over tabs. I have 
never seen a good argument for spaces (and I've seen a lot), so I'll 
try to convince that tabs is the way (god damn it we don't live in 1980 
any more).

From the tutorial: "Tabs introduce confusion, and are best left out." - 
only if you're switching in the middle of a document, tabs and spaces 
are equally confusing (I would say they're the opposite, but ok). 
There's no difference on that part.

Then some of the arguments I've heard is that some editors shows tabs 
badly, although true, then most proper editors it's possible to adjust 
that to your personal preference, removing that possibility you are 
removing a nice (although not entirely needed) flexibility.

In a program with 200 lines of code we have roughly 600 extra 
keystrokes with spaces, unless using a proper editor which shows tabs 
nicely.

Tabs use less space, which is usable when uploading and downloading 
code a lot (which you do when using version control).

Posting on forums is a problem with tabs. True, but then you can use 
proper utilities for that, and although I don't use forums for code 
issues I would seriously question the forum if a code-related forum 
didn't convert tabs, and even if it doesn't then I would still use a 
pastebin utility, since it offers all those nice features like syntax 
highlighting and auto conversion of tabs.

4 spaces is prettier than tabs converted to 8 spaces. True but yet 
again most editors can adjust that or actually use 4 spaces per 
default, but if I like 2 spaces I can't do that without introducing 
confusion, so spaces actually introduces more confusion than tabs.

Good editors makes spaces transparent and behave like tabs, true but 
good editors also makes tabs look pretty. But editing manual spaces is 
hell compared to the ugliness of a bad editor, and I prefer usability 
over pretty.

This don't look good with tabs
string = "some multiline whatever string"+
         " and continued"
string = "some multiline whatever string"+
            " and continued"
True, but not unreadable, and if insisting on pretty you can switch to 
tabs for identation spaces for multiline prettyness.

So until I see good arguments for spaces I would really like to see the 
standard switched to tabs, since I see no good reason for claiming 
spaces is better ... actually so see reason to claim otherwise.
msg93206 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-09-28 13:03
Python started out using tabs, for some of the reasons you elaborate.
Years of practical experience have shown that using tabs causes pain. 
Our recommendation is not going to change.
msg93230 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-09-28 20:01
> Then some of the arguments I've heard is that some editors shows tabs 
> badly, although true, then most proper editors it's possible to adjust 
> that to your personal preference

That is no option for Python. In Python, it is part of the LANGUAGE
SYNTAX that a tab is 8 columns. Changing that may change the very
meaning of a Python program (i.e. an editor configured to four column
tabs may render a program to MEAN something different than when
formatted to eight column tabs).

So a tab is 8 columns, period.

> In a program with 200 lines of code we have roughly 600 extra 
> keystrokes with spaces, unless using a proper editor which shows tabs 
> nicely.

I think you should get a different editor then. I press tab in my
editor and still get four spaces.

> Tabs use less space, which is usable when uploading and downloading 
> code a lot (which you do when using version control).

That's negligible, compared to the rest of the file.
msg93231 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2009-09-28 20:33
Wow. You (rohdef) really do sound like you are a time capsule from the 
eighties. Tabs would save keystrokes and bandwidth, and are not 
confusing? The keystrokes argument is wrong for most editors; the 
bandwidth argument doesn't matter due to disk size, network speed, and 
compression; and the confusion is absolutely real. Pretty much every 
time I volunteer to help out a group of Python newbies there is at least 
one baffling problem due to tabs/spaces. There are hundreds of different 
text editors that people use on a regular basis to edit Python source 
code. They all display spaces the same way; not so for tabs. Most of 
them have configurable behavior for tabs, and most of the time the users 
are not aware of even the existence of those settings, let alone what 
setting is currently being used.
msg93257 - (view) Author: Rohde Fischer (rohdef) Date: 2009-09-29 07:31
> Python started out using tabs, for some of the reasons you elaborate.
> Years of practical experience have shown that using tabs causes pain.
> Our recommendation is not going to change.
I can't actually see why this should be the case, could you please 
enlighten me here?

> > Then some of the arguments I've heard is that some editors shows
> > tabs badly, although true, then most proper editors it's possible
> > to adjust that to your personal preference
> That is no option for Python. In Python, it is part of the LANGUAGE
> SYNTAX that a tab is 8 columns. Changing that may change the very
> meaning of a Python program (i.e. an editor configured to four column
> tabs may render a program to MEAN something different than when
> formatted to eight column tabs).
I fail to see that this is possible, simply from the following reason 
(space after \t added for readability)
if a<b:
\t if b<c:
\t\t # some code

if that ends up as:
if a<b:
    if b<c:
        # Some code

or
if a<b:
        if b<c:
                # Some code

would be exactly the same (apart from how much space it takes). Unless 
the editor automatically wraps lines or some other - for programming - 
inappropriate things, then the code would be exactly the same as long 
as you use the same indentation all the way, no matter if it's 
interpreted as 2, 4, 8 or n spaces.

As far as I can see no matter how complex the code is this wouldn't 
change, since 1st block = 1 tab || 4 spaces, 2nd block = 2 tabs || 8 
spaces. No matter how many blocks, no matter if the editor shows it as 
x spaces the code is the same. Only requirements is, don't mix tabs and 
spaces (but that counts everywhere, just don't do it ;) ), and that you 
indent when using block code (which is also the same for spaces).

> > In a program with 200 lines of code we have roughly 600 extra
> > keystrokes with spaces, unless using a proper editor which shows
> > tabs nicely.

> I think you should get a different editor then. I press tab in my
> editor and still get four spaces.
Ok I though I managed to make it clear that I know the possibilities of 
editors, but ok. I'm perfectly aware of that possibility, but so far 
I'm not interested. I see no reasons for spaces apart from making a lot 
of things harder without benefits (I still fail to see any benefit)

> > Tabs use less space, which is usable when uploading and downloading
> > code a lot (which you do when using version control).

> That's negligible, compared to the rest of the file.

Might be true, but with the present speed of most free svn server even 
little gained is useful. I'm actually disappointed of how bad their 
download is (just in case someone wonders: I have tested my upload)

> Wow. You (rohdef) really do sound like you are a time capsule from
> the eighties. Tabs would save keystrokes and bandwidth, and are not
> confusing? The keystrokes argument is wrong for most editors;
I'm aware (I'm surprised that it's unclear from what I wrote that I'm 
aware of the most basic capabilities of an IDE, but ok that's besides 
the point), but I'm probably not the only one in the world being forced 
to work on crappy editors from time to time, even though I try to avoid 
it.

> the bandwidth argument doesn't matter due to disk size, network
> speed, and compression;
Although it might not be much I still feel that it's a waste, but as 
far as I see this is the only point where I'm like a time capsule from 
the 80's. But still even little saved matters when using SF og Google 
Code for svn (I was a bit shocked on how slow they are, and to be 
honest I use another that's nice and fast in stead).

> and the confusion is absolutely real.
But none has pointed it out yet, the only confusion I've seen so far is 
from people having contradicting beliefs on the tabs vs spaces. So far 
I've never seen a reason to change my opinion, since I've only seen 
spaces as trouble.

> Pretty much every time I volunteer to help out a group of Python
> newbies there is at least one baffling problem due to tabs/spaces.
> There are hundreds of different text editors that people use on a
> regular basis to edit Python source code. They all display spaces
> the same way; not so for tabs.
The beauty of flexibility :) Besides that I've never seen problems due 
to tabs shown differently as long as it's not treated in some insane 
way that would be inappropriate for an IDE, so I won't consider those.

> Most of them have configurable behavior for tabs, and most of the
> time the users are not aware of even the existence of those settings,
> let alone what setting is currently being used.
And since most developers is unaware of things like compile options in 
compiled languages, should we remove that too? Even though most people 
aren't aware (either because of the lack of need or interest to change 
it) of the settings, there's no reason to remove that for us who know 
and care.


I'll try to say what I indirectly said. Show my why things are like you 
say it is. Why is tabs confusing? Why is spaces better? I can't use 
empty arguments without any proof. I can't use a "it's just like that"-
argument, only thing I can use that for is wasting my time.
msg93280 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2009-09-29 11:42
I understand you're annoyed, but the bug tracker is not the place to
rehash arguments that were settled a decade ago.  If you need to pursue
this, please take it to the newsgroup comp.lang.python.  Before you do,
you might want to scour the newsgroup's archives, as millions of words
of debate on this topic have already taken place, mostly in the early to
mid 90's.  Nobody has anything new to say on this topic :-(

Note that nobody objects if you want to use tabs, or even mix tabs and
spaces, in your own code.  The Python "spaces only" standard is for
distributed code.  Years of early experience taught us beyond doubt that
tabs caused endless problems for /shared/ code, to the extent that the
Python distribution contains utilities to detect when mixing tabs and
spaces can cause semantic differences (tabnanny.py) and to reformat
source files to replace all tabs with spaces (reindent.py).

Indeed, if you want to contribute to the Python distribution and insist
on using tabs, that's fine:  simply run your code through reindent.py
before submitting your patch.  Otherwise, just like this feature
request, your patch will be rejected ;-)
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51261
2009-09-29 14:45:41gvanrossumsetnosy: - gvanrossum
2009-09-29 11:42:58tim.peterssetnosy: + tim.peters
messages: + msg93280
2009-09-29 07:31:39rohdefsetmessages: + msg93257
2009-09-28 20:42:36mark.dickinsonsettitle: Tabs is better than spaces for identation -> Tabs is better than spaces for indentation
2009-09-28 20:33:59gvanrossumsetnosy: + gvanrossum
messages: + msg93231
2009-09-28 20:01:43loewissetnosy: + loewis
messages: + msg93230
2009-09-28 13:03:56r.david.murraysetstatus: open -> closed
priority: low


nosy: + r.david.murray
messages: + msg93206
resolution: rejected
stage: resolved
2009-09-28 12:26:23rohdefcreate