"Super()" confusion

Scott David Daniels Scott.Daniels at Acm.Org
Mon Feb 9 18:58:32 EST 2009


Lionel wrote:
> 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):...
> 
> class Child(Parent):
>      def __init__(self, filePath):
>           super(Child,self).__init__(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.

To use super, you must work with descendants of "object".

So, just change your first line to:
     class Parent(object):
and you should find your world back in place.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list