Parsing environment variables in ConfigParser files

Bogdan Marinescu bogdanal at
Fri Dec 19 19:07:32 CET 2003

    Good idea, but since you want to do this, why stop here? I would really
like to have the possibility to expand some previous defined variables in
the file:

var1 = ...

    Of course this should merely complete the environment variable
replacement feature.

----- Original Message -----
From: "Matthew Barnes" <matthew at>
Newsgroups: comp.lang.python
To: <python-list at>
Sent: Friday, December 19, 2003 7:36 PM
Subject: Parsing environment variables in ConfigParser files

> I'm considering submitting a patch for Python 2.4 to allow environment
> variable expansion in ConfigParser files.  The use cases for this
> should be obvious.  I'd like to be able to specify something like the
> following in a configuration file:
>         [section_name]
>         data_file=${HOME}/mydata.dat
> ...(where HOME=/home/matt) and have ConfigParser automatically expand
> it to:
>         [section_name]
>         data_file=/home/matt/mydata.dat
> The change is pretty straight-forward, but I'm interested in feedback
> on whether this is a good idea, what the syntax for environment
> variable references should look like (currently I'm thinking
> ${varname}), or whether there are any hidden complexities or
> backward-compatibility concerns.
> Matthew Barnes
> --

More information about the Python-list mailing list