Re: Printing unix Line endings from Windows.

2006-12-05 Thread Fredrik Lundh
Ant wrote: > Is it worth me submitting a patch to fileinput which can take an > optional write mode parameter? absolutely. -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing unix Line endings from Windows.

2006-12-05 Thread Ant
John Machin wrote: > Ant wrote: ... > > filehandle.write("xxx \n") > > filehandle.write("xxx \x0a") > > > > and all of these give me a nice windows-style crlf! > > > > Surely there must be a way to do this ... > > and there is: open your output file in binary mode; then it won't > convert every \

Re: Printing unix Line endings from Windows.

2006-12-05 Thread John Machin
Ant wrote: > Larry Bates wrote: > > > Ant wrote: > ... > > > Is there any way of doing this without having to post-process the file > > > in binary mode (a-la the crlf.py script) > ... > > You can write to a new file and create your own line endings. > > When done, delete the original file and ren

Re: Printing unix Line endings from Windows.

2006-12-05 Thread Fredrik Lundh
Ant wrote: > How can I create my own line endings? I've tried setting os.linesep = > "\n", (and to \x0a). I've tried things like: > > print "xxx yyy \n", > print "xxx uuu \x0a", > filehandle.write("xxx \n") > filehandle.write("xxx \x0a") > > and all of these give me a nice windows-style crlf! >

Re: Printing unix Line endings from Windows.

2006-12-05 Thread Ant
Larry Bates wrote: > Ant wrote: ... > > Is there any way of doing this without having to post-process the file > > in binary mode (a-la the crlf.py script) ... > You can write to a new file and create your own line endings. > When done, delete the original file and rename the output file. How ca

Re: Printing unix Line endings from Windows.

2006-12-04 Thread Larry Bates
Ant wrote: > Hi all, > > I've got a problem here which has me stumped. I've got a python script > which does some text processing on some files and writes it back out to > the same file using the fileinput module with inplace set to True. > > The script needs to run from Windows, but the files ne

Printing unix Line endings from Windows.

2006-12-04 Thread Ant
Hi all, I've got a problem here which has me stumped. I've got a python script which does some text processing on some files and writes it back out to the same file using the fileinput module with inplace set to True. The script needs to run from Windows, but the files need to be written with Uni