newbie: Windows os.getenv(...

Peter Hansen peter at engcorp.com
Mon Oct 20 09:37:38 EDT 2003


Martin wrote:
> 
> i´d like to use environment variables within an python script.
> I can read with
> >>>t1 = os.getenv("temp")
> but not
> >>>d1 = os.getenv("%date%")

As Diez said, %DATE% is a purely DOS convention with no meaning in
Python.  It's a variable substitution technique using the DATE 
environment variable.

> Also I cannot change environment variables with
> os.putenv("any" , "something")
> 
> Do you have a clue?

You cannot, if you mean you want the changes to persist after your 
script has completed.  On the other hand, there are techniques you
can use to work around the problem.  Try searching the mailing list
or newsgroup archives (e.g. with groups.google.com) for the several
past discussions of this and the answers.

-Peter




More information about the Python-list mailing list