[Tutor] Problem Moving Python Program From WIndows to Linux

D-Man dsh8290@rit.edu
Tue, 10 Apr 2001 10:00:06 -0400


On Tue, Apr 10, 2001 at 06:15:44PM -0800, Jethro Cramp wrote:
| Dear Daniel,
| 
| Thanks alot for the suggestions. Given me several ideas and introduced 
| me to the "continue" function.

<nitpick> it's a keyword, not a function </nitpick>

| Can you recommend any utilities to strip "\r" from files. I tried doing 
| search and replace in idle but that failed.

In vim :

:%s/^V^M//


or you can use the python script Kalle suggested.

| Also if I do strip all the "\r" will that render the scripts inoperable 
| under windows?

No.  I use windows at work and in (g)vim (my favorite editor) I set it
to not include the extra, useless, \r characters on each line.

Where you will run into trouble is if you write the file on a windows
system it will normally translate \n to \r\n in the write operation.
If you treat the file as a text file and look for empty lines rather
than \n expicitly it will work fine across systems.  The other
alternative is to open the (data) file in 'binary' mode.  Then you
will have full control over the contents.  Operating systems really
shouldn't be mangling your files like that anyways (IMO); it's the job
of the library to handle that filetype to do any necessary mangling.

-D