expanduser on windows and wxGlade

Florian Schulze florian.proff.schulze at gmx.net
Wed Dec 11 15:15:45 EST 2002


On Wed, 11 Dec 2002 11:03:41 -0800 Trent Mick <trentm at ActiveState.com> wrote:

> [Florian Schulze wrote]
> > 
> > Hi,
> > 
> > it seems like os.path.expanduser doesn't work as it should on windows,
> or I
> > don't understand how it works.
> > I get this:
> > >>> os.path.expanduser("~")
> > '%USERPROFILE%'
> > But shouldn't this be expanded to the real path to my userprofile
> > directory? I stumbled over this, because wxGlade always gives me an
> error
> > when it trys to save it's config file at exit. It would be really nice
> if
> > someone could enlighten me, or could say it's really a bug.
> 
> Depends on what your environment settings are. os.path.expanduser on
> Windows first uses your "HOME" env var if it exists. Next it tries to
> use HOMEPATH and HOMEDRIVE env. vars. After that it gives up. What are
> your HOME, HOMEPATH, and HOMEDRIVE environment variables?
> 
> If you look in the registry under:
>     HKCU/Environment
> and
>     HKLM/Environment
> are any of HOME, HOMEPATH, or HOMEDRIVE set to "%USERPROFILE%"?
> 
> Trent
> 
> -- 
> Trent Mick
> TrentM at ActiveState.com
> 

Yes, HOME is set to %USERPROFILE%, but isn't that the default? I can't
remember that I ever changed that. TMP and TEMP for example also contain
%USERPROFILE% and USERPROFILE is set when I type set on the commandline. I
think expanduser should also expand any environment variables as far as it
can. I can't even use expandvars, as it expects $varname, not %varname%.

To clarify, I use Win2000 and Python 2.2.2

Florian







More information about the Python-list mailing list