"Super()" confusion

Lionel lionel.keene at gmail.com
Mon Feb 9 18:20:05 EST 2009


Hello. I've been scouring the web looking for something to clear up a
little confusion about the use of "super()" but haven't found anything
that really helps. Here's my simple example:


class Parent:
     def __init__(self, filePath):
       .
       .
       Do some processing with "filePath"
       .
       .

class Child(Parent):
     def __init__(self, filePath):
          super(Child,self).__init__(filePath)
          .
          .
          Do some additional Child-specific processing on filePath
          .
          .

As I understand it, "super()" will invoke the initializer of the base
class. There must be something wrong with the above syntax since I'm
getting:

"super(Child,self).__init__(filePath)
TypeError: super() argument 1 must be type, not classobj"

What have I done wrong? Thanks in advance for any help.

L



More information about the Python-list mailing list