Finding user's home dir

Peter Hansen peter at engcorp.com
Thu Feb 3 21:51:15 EST 2005


Nemesis wrote:
> On my Win2000 box it returns "%USERPROFILE%". That's no surprise because
> if you look at the code it try to use os.environ["HOME"] (as
> os.path.expanduser() does). And on my Win2000 system this information
> points to "%USERPROFILE%" field (I don't know why, I'm not the
> administrator of that machine).

It looks a lot like somebody who didn't test things out
properly (the real administrator, not you), was trying
to do the equivalent of "set home=%userprofile%" but
managed to fail...  if you do that at the command line
or in a .CMD or .BAT file, it will expand the reference
out and you'd have a "HOME=C:\Documents and Settings\whatever"
just like you'd expect.

Probably they put that in a dialog box somewhere without
realizing it wouldn't be evaluated.  (At least, I don't
think environment variable substitution generally or
ever has "lazy evaluation" semantics...)

Now that I know how to do what Duncan described (thanks
Duncan!), either approach works for me.  Of course,
whether I'm a likely eventual user of your particular
program is an entirely different question. ;-)

-Peter



More information about the Python-list mailing list