Environment variables - Expand

Gerrit Holl gerrit at nl.linux.org
Mon May 12 08:08:11 EDT 2003


Dips schreef op maandag 12 mei om 13:17:27 +0000:
> From: dipankarweb at yahoo.co.in (Dips)
> Newsgroups: comp.lang.python
> Subject: Environment variables - Expand
> To: python-list at python.org
> Date: 	Mon, 12 May 2003 13:17:27 +0200
> 
> Hi All,

Hi,

> Is it possible to expand environment variable in Windows using
> one-liner python command?
> 
> For instance, the following command doesn't expand %WINDIR%
> automatically
> file_name = '%WINDIR%\WIN.INI'
> file = os.open(file,'r')
> 
> In actual 'file_name' is fed as command-line argument and so can
> contain any environement variables.

I am not sure what you mean.
Are you looking for os.environ?

  3 >>> import os
  4 >>> os.environ["HOME"]
'/home/gerrit'

See also: http://www.python.org/dev/doc/devel/lib/os-procinfo.html

yours,
Gerrit.

-- 
172. If her husband made her no gift, she shall be compensated for her
gift, and she shall receive a portion from the estate of her husband,
equal to that of one child. If her sons oppress her, to force her out of
the house, the judge shall examine into the matter, and if the sons are at
fault the woman shall not leave her husband's house. If the woman desire
to leave the house, she must leave to her sons the gift which her husband
gave her, but she may take the dowry of her father's house. Then she may
marry the man of her heart. 
        -- Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list