Re: Python doesn't understand %userprofile%
- From: Mike Driscoll <kyosohma@xxxxxxxxx>
- Date: Wed, 11 Jun 2008 04:47:29 -0700 (PDT)
On Jun 11, 1:58 am, Tim Roberts <t...@xxxxxxxxx> wrote:
bsag...@xxxxxxxxx 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, t...@xxxxxxxxx
Providenza & Boekelheide, Inc.
You can use it at the Run command or in Explorer too. If I type
%username% in either place, it opens the following on my XP machine: C:
\Documents and Settings\Mike
Mike
.
- References:
- Python doesn't understand %userprofile%
- From: bsagert
- Re: Python doesn't understand %userprofile%
- From: Tim Roberts
- Python doesn't understand %userprofile%
- Prev by Date: Re: Python regex question
- Next by Date: Re: Parallel python + ??
- Previous by thread: Re: Python doesn't understand %userprofile%
- Next by thread: chained exceptions
- Index(es):
Relevant Pages
|