Tabs versus Spaces in Source Code

Duncan Booth duncan.booth at invalid.invalid
Tue May 16 03:43:03 EDT 2006


achates wrote:

> A tab is not equivalent to a number of spaces. It is a character
> signifying an indent, just like the newline character signifies the end
> of a line. If your editor automatically converts tabs to spaces (i.e.
> you are unable to create source files containing tabs) then either it's
> broken or you have misconfigured it. Either way you probably shouldn't
> be using it to write code.

That is true so far as it goes, but equally if your editor inserts a tab 
character when you press the tab key it is as broken as though it inserted 
a backspace character when you press the backspace key. In both of these 
cases you have an operation (move to next tabstop, move back one space) and 
an ascii control character which is intended to reflect that operation when 
rendering the file to an output device.

An editor should be capable of letting you create or modify files 
containing control characters without gratuitously corrupting them, but the 
keys should perform the expected operations not insert the characters.



More information about the Python-list mailing list