ConfigParser subclass problem

Strato python at p0w.org
Fri Sep 26 15:56:57 EDT 2008


Hi folks,

I think I do something wrong, but I don't see why it doesn't work, so I 
will explain:

I've searched in the list archive and found this thread, that explain 
exactly what I want to have: the options strings returned by 
ConfigParser without being lower cased.

I tryed to reproduce this, by subclassing the SafeConfigParser class, 
like this:

* in my main script:

from MyConfigParser import *

* in the MyConfigParser.py file:
from ConfigParser import SafeConfigParser

class MyConfigParser(SafeConfigParser):
    def optionxform(self, optionstr):
        print "Called the modified version of the class"
        return optionstr

then, when I run the script, every time a calls to my own class is done, 
the print statment is shown in the console, so this may work, but when I 
use the .items() method of the class, I got a lower cased result !

(In my test, using the .items() method is my only try to test the new class)

Does anybody has an idea of what I'm doing wrong ?

Thanks,
Strato




More information about the Python-list mailing list