How about doing something like
host.name=%HOSTNAME%
Then when you parse in the value %HOSTNAME% from your configParser module you
do a pattern substitution of %HOSTNAME% with os.environ['HOSTNAME'].
Sent from my iPhone 4.
On Oct 14, 2010, at 7:57 PM, pikespeak wrote:
> Hi,
> I am using ConfigParser module and would like to know if it has the
> feature to autoexpand environment variables.
> For example currently, I have the below section in config where
> hostname is hardcoded.
> I would like it to be replaced with the values from the env variable
> os.envion['HOSTNAME'] so that I can remove hardcoding and my config
> will be host independent.
>
> [section]
> host.name=devserver1.company.com
>
> to be replaced with something like this
>
> [section]
> host.name=os.environ['HOSTNAME']
>
> I know of the interpolation feature of Config Parser %{foo}s where
> value of foo will be expanded..but not sure if this can be tweeked to
> my needs.
>
> Any ideas please.
>
> srini
>
> --
> http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list