Subclassing ConfigParser question

Gary Richardson garyr at fidalgo.net
Wed Nov 26 10:07:46 EST 2003


"Roy H. Berger" <roybrew at att.net> wrote in message
news:b62ff6e.0311250836.7460f2 at posting.google.com...
> If I want to subclass ConfigParser and changed the optionxform method
> to not return things in lower case wouldn't I just need the following
> code in my subclasss module?
>
> from ConfigParser import *
>
> class MyConfigParser(ConfigParser):
> def __init__(self, defaults=None):
> ConfigParser.__init__(self, defaults)
>
> def optionxform (self, optionstr):
> return optionstr
>
> Or do I need to re-implement all of the methods of ConfigParser?
> Sorry -- haven't done much subclassing with python.
>
> Thanks in advance.
>
> Roy
> roybrew at att.net

Can't you just write:

cp = ConfigParser.ConfigParser()
cp.optionxform = str

to accomplish the same thing? That seems to be what the documentation
implies.






More information about the Python-list mailing list