Python doesn't understand %userprofile%

Duncan Booth duncan.booth at invalid.invalid
Tue Jun 10 20:09:06 CEST 2008


bsagert at gmail.com 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'



More information about the Python-list mailing list