Re: Getting the home directory in Python and a bug in os.path.expanduser



Edward Diener:

Probably most reliable on Windows is a Windows API function, if it exists, for getting the home directory, as opposed to using environment variables, but I can not find any Windows API for it at present.

Look at SHGetFolderPath(CSIDL_PROFILE, ...) for Windows Me/2000 or later. CSIDL_APPDATA is probably a better idea than CSIDL_PROFILE (its equivalent to "%USERPROFILE%\Application Data" and roams) but %USERPROFILE% (CSIDL_PROFILE) is compatible with previous Python behaviour.
http://msdn2.microsoft.com/en-us/library/ms647764.aspx

Neil
.



Relevant Pages

  • Re: Getting the home directory in Python and a bug in os.path.expanduser
    ... Neil Hodgson wrote: ... exists, for getting the home directory, as opposed to using environment variables, but I can not find any Windows API for it at present. ...
    (comp.lang.python)
  • Re: VBA / VBS to get Desktop folder string
    ... How I am supposed to know how reliable the API is, ... programmers who design these applications make use of environment variables ... bypassing the Windows API set up for just this purpose, ... written will always be more secure than the Windows Registry, ...
    (microsoft.public.access.modulesdaovba)
  • Re: VBA / VBS to get Desktop folder string
    ... How I am supposed to know how reliable the API is, ... programmers who design these applications make use of environment variables ... bypassing the Windows API set up for just this purpose, ... written will always be more secure than the Windows Registry, ...
    (microsoft.public.access.modulesdaovba)
  • Re: what exactly does HOME enviroment variable?
    ... > can i say that the command set return me a path to my HOME DIRECTORY? ... the login manpage for the environment variables set when you log in. ...
    (comp.unix.questions)
  • Re: env(USERPROFILE) question
    ... >In NT related versions of Windows there is an 'env' ... >variable that tells where the user's home directory is located. ... has nothing to do with Tcl. ... Tcl exposes all environment variables it encounters ...
    (comp.lang.tcl)