On Oct 6, 11:31 pm, goldtech <[EMAIL PROTECTED]> wrote: > Can anyone link me or explain the following: > > I open a file in a python script. I want the new file's location to be > on the user's desktop in a Windows XP environment. fileHandle = open > (....., 'w' ) what I guess I'm looking for is an environmental > variable that will usually be correct on most XP desktops and will > work in the open statement. Or is there another way? This is really a Windows question, not a Python question. You should have been able to figure it out yourself by examining existing environment variables. Something like the code below should work for you if the standard environment variables haven't been hosed. ---------- import os Filename = os.getenv("HOMEDRIVE") + os.getenv("HOMEPATH") + "\\Desktop \MyNewFile" f = file(Filename, "w") f.write("Here's a file on the desktop\n") f.close()
-- http://mail.python.org/mailman/listinfo/python-list