Help with ConfigParser

TonyHa tony_ha2002 at yahoo.co.uk
Mon Oct 2 10:29:49 EDT 2006


Hello Peter,

Thanks for your help, and it works now!

Tony.

Peter Otten wrote:
> tony.ha at philips.com wrote:
>
> > Question: How can I pervent ConfigParse to convert Upper case yo lower
> > case??, thanks.
>
> http://docs.python.org/dev/lib/RawConfigParser-objects.html
>
> """
> optionxform(option)
>
> 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()
> # ...
> 
> Peter




More information about the Python-list mailing list