python 2.0 won't run scripts with \r\n line termination on RH7?

Mike Carifio carifio.nospam at nospam.usys.com
Tue Feb 13 08:11:47 EST 2001


I don't want to provoke an argument. And I certainly won't try to defend the
'^M' hack in the file name itself.
But other technologies that started on Unix have made some accomodations to
the pragmatics of other
platforms (typically starting with 'W'). Python itself, for example, doesn't
choke on \r\n or \n lines. I have a hetrogeneous environment, not all my
scripts are under CVS control and I don't want to have to remember if I'm
creating a Unix file with a Windows utility or a Windows file with a Unix
utility and so forth. If bash accomodated
both \r\n and \n at the end of the first line, I wouldn't be asking the
question because it wouldn't matter. It
would just work.

In any event, the original question was "are there work arounds?" To
summarize the answers:

1) Yes, but the workarounds are crufty. Obey the \n rule. In some cases, you
can get your favorite editor
     or IDE to do it for you regardless of platform.
2) You can graft \r onto the python filename. Pro: you can create scripts
from Windows or Linux on the native
     file system or over Samba. Cons: You can't pass additional arguments,
it leaves a foul taste in your mouth.
3) If you put your scripts under source code control, you can convert end of
line on checkout.

All this was helpful. Thanks.





More information about the Python-list mailing list