On 12 Feb, 16:53, Tim Golden <[EMAIL PROTECTED]> wrote: > billie wrote: > > Do you got any idea about how getting user's home directory? > > The answer to that is unfortunately slightly complicated, > because Windows has no such thing as a "user's home directory" > or, if you prefer, it has several such things. > > If you want, you can let Python make the decision, by > calling os.path.expanduser on "~" which, in my case, > correctly gives h:\ which is my domain home directory. > > Obviously this is not necessarily the same as my Documents > and Settings directory, which can also be considered a home > directory. That you can get by querying the shell: > > <code> > from win32com.shell import shell, shellcon > > idlist = shell.SHGetSpecialFolderLocation (0, shellcon.CSIDL_PERSONAL) > documents_and_settings = shell.SHGetPathFromIDList (idlist) > print documents_and_settings > > </code> > > In my case they are the same but that will depend on your > setup. I know in the past at least one of these has > defaulted to c:\ > > Alternatives (which in my case amount to the same thing) > include using the HOMEDRIVE / HOMEPATH / HOMESHARE > environment vars: > > <code> > import os > drive = os.environ.get ("HOMEDRIVE", "") > path = os.environ.get ("HOMEPATH", "") > > share = os.environ.get ("HOMESHARE", "") > > print drive+path > print share > </code> > > I haven't bothered to look, but I think this latter > is how the expanduser function works things out. > > YMMV > TJG
Thanks. -- http://mail.python.org/mailman/listinfo/python-list