windows and home path

Jerry Hill malaclypse2 at
Tue Jan 24 11:21:40 EST 2012

On Tue, Jan 24, 2012 at 11:10 AM, Andrea Crotti
<andrea.crotti.0 at> wrote:
> 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..

It would not do the trick on my windows XP workstation here.  Your
target environments may be different, of course.  From a general
command prompt (cmd.exe) on my work machine, here's what you would
have to work with:

USERPROFILE=C:\Documents and Settings\username

There is no HOME set here.  So, what's the right home directory for me
on this PC?  Depending on your opinion of "right" you could end up
with three different answers:  "H:\", "\\server\share\userdirectory",
or "C:\Documents and Settings\username" all seem like valid candidates
to me.  Just going by HOMEPATH isn't going to be helpful if I were to
run your code though.


More information about the Python-list mailing list