Tabs versus Spaces in Source Code
sybrenUSE at YOURthirdtower.com.imagination
Wed May 17 10:07:16 CEST 2006
Duncan Booth enlightened us with:
> It is strange. You use many of the same words as me, but they don't make
> any sense.
You forgot to add "to me" to the end of that sentence. Personally,
Achates' words made perfect sense to me.
> The point is about separating the presentation of the source file
> from the semantic content. When displaying the file you can choose
> to expand tabs to any suitable positions. These may be evenly spaced
> every n characters, or may vary across the page.
> However the important thing is that a tab does not map to a single
> indentation level in Python: it can map to any number of indents,
True, but doesn't the same hold for spaces? An indent level can be
made from any number of spaces. You could use two spaces to indent a
class' contents, four for functions, and two again for loops.
> and unless I know the convention you are using to display the tabs I
> cannot know how many indents are equivalent to a tabstop.
That is only true if you mix spaces and tabs. If you use only tabs OR
only spaces to indent, everything is perfectly clear.
>> Seriously people, this is about separating the content of a source
>> file from how it is displayed. It's about letting people work
>> together while also allowing them to have control over their own
>> environments, something which is and always has been central to the
>> hacker ethos.
> Precisely. Using spaces everywhere allows this
No it doesn't! I have tabstops every four characters, which is a
pleasant indent level for me. Other people have trouble reading the
code that way, and want two or eight character wide indents. When
using tabs, everybody can place the tabstops for themselves, and as
long as tabstop N is more to the left than tabstop N+1, everything is
fine. By using spaces, the writer of the code determines the size of
the indentation, not the viewer. Since code is generally read more
than it is written, the viewer is quite important.
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
More information about the Python-list