Using super()

Pupeno pupeno at pupeno.com
Wed Jul 19 08:16:35 EDT 2006


Hello,
I have a class called MyConfig, it is based on Python's
ConfigParser.ConfigParser.
It implements add_section(self, section), which is also implemented on
ConfigParser.ConfigParser, which I want to call.
So, reducing the problem to the bare minimum, the class (with a useless
add_section that shows the problem):

>>> class MyConfig(ConfigParser):
...     def add_section(self, section):
...             super(MyConfig, self).add_section(section)
... 

Create an object

>>> m = MyConfig()

and call the problematic method:

>>> m.add_section("blah")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 3, in add_section
TypeError: super() argument 1 must be type, not classobj
>>> 

Why is super() requiring a type ? doesn't it work with classes ? Is there a
way to achieve what I am trying to do (other than calling the specific
class that happens to be the parent today) ?

Thanks.
-- 
Pupeno <pupeno at pupeno.com> (http://pupeno.com)



More information about the Python-list mailing list