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

Stuart D. Gathman stuart at bmsi.com
Wed Dec 5 22:28:01 EST 2001


On Tue, 04 Dec 2001 19:58:25 -0500, Tim Peters wrote:

> [Erik de Castro Lopo]
>> Please explian to us rational people why that is nasty.
> 
> I've lost track, but I'm pretty sure it was either because the example
> used tabs, or because it used spaces.

Alexis Layton posted a really good idea in another thread.  Instead of
just looking at the indent level, compare indent strings.  Indent strings
are compared considering TAB as greater than SPACE.  This is easily
visualized by converting SPACE to 'S' and TAB to 'T'.  So leading
indentation might be (in increasing indent level):

SSSS
T
TSSSS
TT

Provided that all tabs precede all spaces in the leading indentation, and
that the tab expansion value is sufficiently large (>= 4 in the above
example), any editor will display the indentation in a visually consistent
manner.

It would be reasonable for python to allow mixed tabs + spaces, but
require a strict structuring like the above (which is what the "optimize
whitespace" option outputs on any editor I've seen, including vi/m).

-- 
	      Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.



More information about the Python-list mailing list