How to write dos newline in unix?

Inyeol Lee inyeol.lee at
Wed Jun 9 20:12:38 CEST 2004

Is there any simple way to dos-style newline (\r\n) in *nix environment,
not by writing "\r" explicitly? What I'm trying to do is;

ofile = file("foo", "w")
print "hello, world"

Then it writes "hello, world\r\n".

I tried to assign "\r\n" to ofile.newlines but failed because it's
read-only attribute.

Inyeol Lee

More information about the Python-list mailing list