Python doesn't understand %userprofile%

Tim Roberts timr at probo.com
Wed Jun 11 02:58:49 EDT 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.

For the record, the %PERCENT% syntax for looking up an environment variable
is just a feature of the XP command shell.  It has no meaning to any other
part of Windows.

os.environ is the right answer.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list