How to write dos newline in unix?

Inyeol Lee inyeol.lee at siimage.com
Wed Jun 9 14:14:39 EDT 2004


On Wed, Jun 09, 2004 at 11:12:38AM -0700, Inyeol Lee wrote:
> 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

Typo in the code above. My intention was;

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

Inyeol Lee




More information about the Python-list mailing list