Problem with subprocess module on Windows with open file in append mode

Andrew Savige ajsavige at yahoo.com.au
Sat Oct 3 20:53:12 EDT 2009


When I run this little test program on Linux:

import subprocess
subprocess.call(["python","-V"], stderr=open("log.tmp","a"))

the file log.tmp is appended to each time I run it.
When I run it on Windows, however, the file log.tmp gets
overwritten each time I run it.

Though I can make it append on Windows like this:

import os
import subprocess
f = open("log.tmp", "a")
f.seek(0, os.SEEK_END)
subprocess.call(["python","-V"], stderr=f)

I don't understand why that should be necessary.

Is this a Python/subprocess bug on Windows?

(I tested with Python 2.5.1 and Python 2.6.2 on Windows XP SP2).

Thanks,
/-\



      __________________________________________________________________________________
Get more done like never before with Yahoo!7 Mail.
Learn more: http://au.overview.mail.yahoo.com/



More information about the Python-list mailing list