Tabs are EVIL *and* STUPID, end of discussion. (Re: Tabs versus Spaces in Source Code)

William Studenmund wrstuden at
Thu May 18 01:11:13 CEST 2006

Hash: SHA1

On May 17, 2006, at 8:46 PM, Edward Elliott wrote:

> Dave Hansen wrote:
>> On Wed, 17 May 2006 17:28:26 GMT in comp.lang.python, Edward Elliott
>>> Just for the sake of completeness:
>>> cat file |sed 's/\t/    /g'
>> That doesn't always work.  If you don't see why, you don't understand
>> my objection to TAB characters in text files.
>>> less -x4 file
>> That will work.  As long as the creator of file used four-space TABs,
>> anyway...
> I fail to see why less 'will work' but cat 'doesn't always work'.   
> The net
> effect of both is the same.  Unless you're in some weird place that  
> pipes
> aren't allowed, these should be equivalent:

I don't think that cat is the problem, it's sed.

The problem is that tabs take you to the next tab stop, they don't  
expand to a fixed number of spaces.

Consider the strings "\t\t", "\t \t", and "\t  \t". With everything  
except one- or two-space tab settings (less -x1 or less -x2), the  
spaces haven't moved us past a tab stop, so the \t after them takes  
us to the same tab stop in all cases.

Take care,

Version: GnuPG v1.4.1 (Darwin)


More information about the Python-list mailing list