Tabs versus Spaces in Source Code

Kaz Kylheku kkylheku at
Wed May 17 00:01:18 CEST 2006

achates wrote:
> Kaz Kylheku wrote:
> > If you want to do nice typesetting of code, you have to add markup
> > which has to be stripped away if you actually want to run the code.
> Typesetting code is not a helpful activity outside of the publishing
> industry.

Be that as it may, code writing involves an element of typesetting. If
you are aligning characters, you are typesetting, however crudely.

> You might like the results of your typsetting; I happen not
> to. You probably wouldn't like mine. Does that mean we shouldn't work
> together? Only if you insist on forcing me to conform to your way of
> displaying code.

Someone who insists that everyone should separate line indentation into
tabs which achieve the block level, and spaces that achieve additional
alignment, so that code could be displayed in more than one way based
on the tab size without loss of alignment, is probably a "space cadet",
who has a bizarre agenda unrelated to developing the product.

There is close to zero value in maintaining such a scheme, and
consequently, it's hard to justify with a business case.

Yes, in the real world, you have to conform to someone's way of
formatting and displaying code. That's how it is.

You have to learn to read, write and even like more than one style.

> You are correct in pointing out that tabs don't allow for 'alignment'
> of the sort you mention:

That alignment has a name: hanging indentation.

All forms of aligning the first character of a line to some requirement
inherited from the previous line are called indentation.

Granted, a portion of that indentation is derived from the nesting
level of some logically enclosing programming language construct, and
part of it may be derived from the position of a character of some
parallel constituent within the construct.

> (lisp
>    (nested list
>     with symbols
>     and things))
> But then neither does Python. I happen to think that's a feature.

Python has logical line continuation which gives rise to the need for
hanging indents to line up with parallel constituents in a folded

Python also allows for the possibility of statements separated by
semicolons on one line, which may need to be lined up in columns.

   var = 42; foo = 53
   x   =  2; y   = 10

> (And of course you can do what you like inside a comment. That's
> because tabs are for indentation, and indentation is meanigless in that
> context.

A comment can contain example code, which contains indentation.

What, I can't change the tab size to display that how I want? Waaah!!!

More information about the Python-list mailing list