How to create a file on users XP desktop

Craig Howard craig.howard at earthlink.net
Sun Oct 7 11:12:58 CEST 2007


On Oct 6, 2007, at 11:31 PM, goldtech 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?
>
> Thanks
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list

import os.path
home = os.path.expanduser('~')
desktop = os.path.join(home, 'Desktop')



More information about the Python-list mailing list