[Tutor] Superclass call problem

Alan Harris-Reid aharrisreid at googlemail.com
Sun Feb 21 00:55:18 CET 2010

Luke Paireepinart wrote:
> Your call to super is wrong. It should be super and you pass the class
> and instance, then call init.
> On 2/20/10, Alan Harris-Reid <aharrisreid at googlemail.com> wrote:
>> Hi,
>> I am having trouble understanding how superclass calls work.  Here's
>> some code...
>> class ParentClass():
>>     def __init__(self):
>>         do something here
>> class ChildClass(ParentClass):
>>     def __init__(self):
>>        super().__init__(self)                 # call parentclass
>> __init__ method
>>        do something else here
>> When the super().__init__ line runs I get the error "__init__() takes
>> exactly 1 positional argument (2 given)"
>> Can anyone tell me where I have gone wrong?  I thought the self
>> parameter should be passed to all class methods.
>> TIA
>> Alan Harris-Reid
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
Hi Luke, thanks for the reply,

In addition to your suggestion, looks like I can use

class ChildClass(ParentClass):
    def __init__(self, arg):
        super(ParentClass, self).__init__(arg)
        super().__init__(arg)        # this only works in Python 3, I think

I prefer the 2nd way, as it is more generic (ie. don't need to state 


More information about the Tutor mailing list