windows and home path

Andrea Crotti andrea.crotti.0 at gmail.com
Tue Jan 24 11:10:07 EST 2012


On 01/24/2012 04:05 PM, Jerry Hill wrote:
>
> The os.path.exanduser() docs (
> http://docs.python.org/library/os.path.html#os.path.expanduser ) say
> that "On Windows, HOME and USERPROFILE will be used if set, otherwise
> a combination of HOMEPATH and HOMEDRIVE will be used. An initial ~user
> is handled by stripping the last directory component from the created
> user path derived above."
>
> So, my guess is that emacs is mangling your HOME environment variable.
>   That appears to be confirmed by the emacs documentation here:
> http://www.gnu.org/software/emacs/manual/html_node/emacs/General-Variables.html#General-Variables
> .
>
> At a guess, you do not have a system-wide HOME environment variable.
> When you launch python from the command line, it uses either your
> USERPROFILE setting, or is falling back to using HOMEDIRVE and
> HOMEPATH.  When you launch emacs, it sees that HOME is not set, and
> emacs helpfully sets it for you, to whatever path it thinks is
> correct.  That would explain why you see different answers in
> different environments.
>
> Does that explain the behavior you're seeing?
>

Ah yes thanks for the explanation, on Python 2.7 on Linux I don't see
the same doc, it might have been updated later..
Anyway I just want to make sure that I get always the same path,
not depending on the program.

 From a first look it seems that just using os.getenv('HOMEPATH') on
windows might make the trick..



More information about the Python-list mailing list