Reputation: 13135
class A:
def start(self):
pass
class B(A):
def start(self):
super(A,self).start()
b = B()
b.start()
Gives this error:
Traceback (most recent call last):
File "C:/Python32/a.py", line 10, in <module>
b.start()
File "C:/Python32/a.py", line 7, in start
super(A,self).start()
AttributeError: 'super' object has no attribute 'start'
Why?
Upvotes: 1
Views: 69
Reputation: 80771
As explained in python doc, super works only for new style class, ie :
Note super() only works for new-style classes.
So you should do something like this :
class A(object): # inherit from object to be a new style class
def start(self):
pass
class B(A):
def start(self):
super(B,self).start() # the first arg of super is the current class
b = B()
b.start()
Upvotes: 7