Issue
class car(object):
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0
class electricCar(car):
def __init__(self, make, model, year):
super().__init__(make, model, year)
tesla = electricCar('tesla', 'model s', 2016)
print tesla.get_descriptive_name()
TypeError: super() takes at least 1 argument (0 given)
what is the problem with the super() function ?
Solution
super()
(without arguments) was introduced in python3
Here is python2 implementation.
class electricCar(car):
def __init__(self, make, model, year):
super(electricCar,self).__init__(make, model, year)
you could refer this question for general inheritance syntax issue regarding python2 and python3
Answered By - Mehari Mamo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.