Deprecate tabs for indenting (was Re: Indenting with tabs vs spaces)

Quinn Dunkan quinn at chunder.ugcs.caltech.edu
Mon Dec 3 18:17:22 EST 2001


Just to fan the flames :)

On Mon, 03 Dec 2001 09:21:48 -0000, Steve Lamb <grey at despair.dmiyu.org> wrote:
>    As you just said, "You should be able to configure your editor to display
>tabs..."  Oh, so a tab isn't a tab.  I like indention of 4 so my tab is 4
>spaces.  You like 8 so yours is 8 spaces.  A tab is not a tab.  A tab is a
>collection of spaces, visually.
>
>    Now, if you had read my post you would have seen where your whole "a tab
>is a tab" bubbub breaks down.  Here it is AGAIN since you missed it the first
>time.
>
>some_dict = {'Jane':{'Age':'21', 'Dept':'0001', 'Ext':'1234'},
>             'John':{'Age':'22', 'Dept':'0010', 'Ext':'5678'},
>             'Jeff':{'Age':'23', 'Dept':'0100', 'Ext':'9009'},
>             'Jody':{'Age':'24', 'Dept':'1000', 'Ext':'8765'},
>             'Jeny':{'Age':'25', 'Dept':'0110', 'Ext':'4321'}
>            }
>
>    With spaces that always comes out the same.  With tabs set to different

Not for me it doesn't, when I use proportional fonts.

>lengths you get different results.  The only constant when it comes to
>indention is a space.  A space is a space.  A tab is not constant and
>therefore should NOT be used for indention.  Ever.

A space is not constant either.

>    Indention isn't about preference, it is about making the code readable.
>And as the above example shows, readable code could be rendered unreadable by
>tab "preferences".

In a proportional font, spaces are usually pretty narrow.  Code that uses two
spaces to indent is hard to read.  Four is sort of ok, but hard to edit.  Code
that insists on trying to line stuff up with spaces is very hard to read.
Code that uses tabs to indent is always readable.

Indentation is not the issue, it's the cute formatting.

My solution is:

1 - Use tabs to indent.
2 - Lose the cute formatting. The above becomes:

some_dict = {
	'Jane' : { ...
	'John' : { ...
}

That should come out ok no matter what people do with their tabs or spaces.
As long as you stay away from lisp and haskell type indentation.

(and in haskell I use real tabs anyway, because the editor gets misled by the
literate birdtracks and puts in not-enough spaces)



More information about the Python-list mailing list