ConfigParser Keys

Tony Meyer t-meyer at ihug.co.nz
Thu Jun 24 07:32:14 CEST 2004


> To my chagrin, I've just discovered that SafeConfigParser, by 
> default, returns all the keys in the key/value pairing in lowercase 
> (what earthly possible reason it would do this I do not know!).  Does 
> anyone know of a way of stopping it doing this?

Sure, just subclass it:

"""
class MySafeConfigParser(SafeConfigParser):
    def optionxform(self, optionstr):
        return optionstr
"""

(And use MySafeConfigParser where you would SafeConfigParser, or do
something ugly like "SafeConfigParser = MySafeConfigParser").

=Tony Meyer





More information about the Python-list mailing list