case-sensitive configparser without magical interpolation?

Ian Kelly ian.g.kelly at gmail.com
Fri May 22 13:12:12 EDT 2015


On Fri, May 22, 2015 at 10:59 AM,  <georgeryoung at gmail.com> wrote:
> [python 2.7]
> I need to use a configparser that is case-sensitive for option names, but does not do magical interpolation of percent sign.
> I.e.:
>
> [Mapping0]
> backupHost = eng%26
> dbNode = v_br_node0001
>
> should be read (and later written) as is, including capitalization and the percent sign.
>
> I find that RawConfigParser keeps the %, but downcases the option name.
> And SafeConfigParser can be hacked with optionxform to be case-sensitive, but does interpolation.
> How can I get case-sensitive but no interpolation?

RawConfigParser also has the optionxform method; have you tried overriding that?

If that doesn't work, then how strict is the 2.7 requirement? In 3.2
or later, the ConfigParser takes an interpolation keyword argument
that can be used to disable interpolation:

https://docs.python.org/3.4/library/configparser.html#configparser-objects



More information about the Python-list mailing list