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

William Studenmund wrstuden at wasabisystems.com
Wed May 17 19:11:13 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
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,

Bill
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEa62XDJT2Egh26K0RAhFUAJ0WWgTRS570DsHAUl0oij47qNoIfgCgiVyV
9vZQUBAOspWLfuom2Scy4MY=
=wmWa
-----END PGP SIGNATURE-----



More information about the Python-list mailing list