Help with ConfigParser

Peter Otten __peter__ at
Mon Oct 2 15:50:57 CEST 2006

tony.ha at wrote:

> Question: How can I pervent ConfigParse to convert Upper case yo lower
> case??, thanks.


Transforms the option name option as found in an input file or as passed in
by client code to the form that should be used in the internal structures.
The default implementation returns a lower-case version of option;
subclasses may override this or client code can set an attribute of this
name on instances to affect this behavior. Setting this to str(), for
example, would make option names case sensitive. 

If you don't pass defaults:

config = ConfigParser()
config.optionxform = str
# ...

Or, to be on the safe side:

class MyCasePreservingConfigParser(ConfigParser):
    optionxform = str

config = MyCasePreservingConfigParser()
# ...


More information about the Python-list mailing list