What is a shortcut to the Default home directory in Windows
Jerry Hill
malaclypse2 at gmail.com
Fri Jan 18 15:34:17 EST 2008
On Jan 18, 2008 3:19 PM, Daniel Folkes <danfolkes at gmail.com> wrote:
> I am trying to write a file to the users file system.
>
> I need it to be in there home directory in WINDOWS. I know there is a
> "shortcut" to home in Linux("~"), but is there an equivalent to that
> in windows. Or to get to their "Documents and Settings" directory?
The easiest way is os.path.expanduser('~')
That works on both unix and windows. It gets you the user's home
directory on unix, and on windows I think it is based on the
environment variables %HOMEDRIVE% and %HOMEPATH%. If that doesn't
give you what you're looking for, you'll need to look into the
environment variables, the registry, or windows system calls,
depending on exactly what you need.
--
Jerry
More information about the Python-list
mailing list