Parsing environment variables in ConfigParser files

Bogdan Marinescu bogdanal at b.astral.ro
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:

[sect1]
var1 = ...
.............
expansion=${var1}

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

----- Original Message -----
From: "Matthew Barnes" <matthew at barnes.net>
Newsgroups: comp.lang.python
To: <python-list at python.org>
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
> --
> http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list