DOS, UNIX and tabs

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Wed Dec 27 18:56:33 EST 2006


Ben schreef:
> I have a python script on a unix system that runs fine. I have a python
> script on a windows system that runs fine. Both use tabs to indent
> sections of the code. I now want to run them on the same system,
> actually in the same script by combining bits and pieces. But whatever
> I try my windows tabs get converted to spaces when I transfer it to the
> unix system and the interpreter complains that the indentation style is
> not consistant throughout the file. Short of going through 350 lines of
> code and manually replacing spaces with tabs what an I do? I'm thinking
> there surely must be a simple solution I have missed here!

How do you transfer the files or their contents from Windows to Unix and 
vice versa? Whatever means you use shouldn't change the file contents, 
except possibly conversion of line endings.

What editors do you use on both systems? Maybe it's just the way one of 
your editors is configured? Are you sure there are tabs in the files, or 
does one of your editors automatically convert them to spaces? Maybe 
it's not a bad idea to view your Windows files with a Windows-based hex 
editor to make sure the indentation is really made up of tabs.

BTW I'm a proponent of spaces instead of tabs, but indentation by tabs 
only (i.e. not a mixture of tabs and spaces) is an acceptable solution 
too and it should work.

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven



More information about the Python-list mailing list