Tabs -vs- Spaces: Tabs should have won.

Thorsten Kampe thorsten at thorstenkampe.de
Sun Jul 17 12:42:21 CEST 2011


* Andrew Berg (Sun, 17 Jul 2011 05:02:22 -0500)
> > And if we work on a project together, we have to agree on formatting
> > anyway, the indent size being the least important one.
> How is indent size unimportant with regard to formatting?

Take some code or yours and format it with three and with six spaces. 
Then you will see how unimportant it is: it looks virtually the same.

Or as I've written in another posting:
"There is for instance maximum line length, the number of empty lines, 
the author's method of alignment, spaces between the equals sign and so 
on. These are all much more "dominant" in the source code and none of 
this is left for the reader's disposition.

Compare for instance

variable        = 11
anothervariable = 22

def whatever (prettylong     = 1,
              alsoprettylong = 22,
              anotherone     = 33):
    pass

to

variable=11
anothervariable=22
def whatever (prettylong=1, alsoprettylong=22, anotherone=33):
    pass"


> > This whole debate is artificial.
> Only if no one cares about your code.

Only if you don't care about indent length - which I again state, most 
people (probably) don't.

> It's also worth mentioning that some people have an almost religious
> fervor when it comes to spaces and tabs.

I know. These are people like rantingrick who start artificial threads 
like this with artificial problems like tabs versus spaces to liberate 
the common coder.

> > Sorry, you didn't understand my point. My point is: the distinction
> > between indentation and alignment is superficial. Indentation /is/
> > exactly the same as alignment.

> I still don't understand. Whitespace to the left of an assignment to
> signify an indent and whitespace around operators to align values (in
> a multi-line assignment) are not the same.

When I'm (consistently, of course) indenting code, I'm aligning it. When 
I'm aligning code, I do this by indenting it, see for instance...

firstvariable = 11
variable      = 111

firstvariable = 22
variable =      222

The second "=" and the "222" is indented.

Or your example:
setup(
    name         = 'Elucidation',
    version      = '0.0.1-WIP',
    py_modules   = ['elucidation'],
    author       = 'Andrew Berg',
    author_email = 'bahamut at digital-signal.net',
    url          = '',
    platforms    = 'Windows',
    description  = 'Provides a class for storing information on
multimedia files that are to be converted or remuxed and methods to
convert and remux using popular tools.'
    )

The keywords are aligned by indenting. In the "left of an assignment" 
case it makes a difference for the Python compiler, in the alignment 
case it doesn't. In both cases, it makes a difference to the human who 
indents/aligns to group similar things and blocks.

Thorsten



More information about the Python-list mailing list