[issue7012] Tabs is better than spaces for indentation
report at bugs.python.org
Tue Sep 29 09:31:45 CEST 2009
Rohde Fischer <krdata at gmail.com> added the comment:
> 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)
\t if b<c:
\t\t # some code
if that ends up as:
# Some code
# 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
> 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
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.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list