Python doesn't understand %userprofile%

drobinow at drobinow at
Tue Jun 10 20:21:42 CEST 2008

On Jun 10, 2:09 pm, Duncan Booth < at invalid.invalid> wrote:
> bsag... at wrote:
> > In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
> > bites back with "cannot find the path specified" Since my script has
> > to run on machines where the username is unspecified I need a fix.
> > Thanks in advance.
> >>> os.path.expanduser("~/dir/file")
> 'C:\\Documents and Settings\\Duncan/dir/file'

"~" appears to look first at the HOME environment variable.
That is not necessarily the same as "USERPROFILE". On my machine it is

More information about the Python-list mailing list