Problem with subprocess module on Windows with open file in appendmode

Discussion in 'Python' started by Andrew Savige, Oct 4, 2009.

  1. 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/
    Andrew Savige, Oct 4, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David S.
    Replies:
    0
    Views:
    419
    David S.
    Feb 16, 2005
  2. Dr. Who
    Replies:
    1
    Views:
    279
    Dr. Who
    Jul 21, 2005
  3. hiral
    Replies:
    2
    Views:
    595
    Jean-Michel Pichavant
    May 5, 2010
  4. Replies:
    0
    Views:
    455
  5. Claudiu Nicolaie CISMARU
    Replies:
    5
    Views:
    902
    Claudiu Nicolaie CISMARU
    May 25, 2011
Loading...

Share This Page