Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19349

Re: windows and home path

References <4F1EC695.9000909@gmail.com>
Date 2012-01-24 11:05 -0500
Subject Re: windows and home path
From Jerry Hill <malaclypse2@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5032.1327421142.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jan 24, 2012 at 9:56 AM, Andrea Crotti
<andrea.crotti.0@gmail.com> wrote:
> Window never stops to surprise me, I've been banging my head since yesterday
> and only
> now I now what is the problem.
>
> So suppose I have something like
>
> from os import path
> print path.expanduser('~')
>
> If I run it from cmd.exe I get /Users/user, doing the same in an emacs
> eshell buffer I get
> /Users/user/AppData/Roaming.
>
> What sense does it make??
> Is there a way to get always the same variable from python somehow?

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?

-- 
Jerry

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: windows and home path Jerry Hill <malaclypse2@gmail.com> - 2012-01-24 11:05 -0500

csiph-web