I am creating a subclass, but I am having difficulties making it inherit from the parent class:
def ParentClass(object):
def __init__(self,num):
self.num = num
self.get_soup()
def get_soup(self):
self.soup = 'soup'
return self.soup
def SubClass(Advert):
def __init__(self,num):
ParentClass.__init__(self,num)
def test(self):
print 'it works'
print self.num
if __name__== "__main__":
num = 1118868465
ad = SubClass(num)
ad.test()
Should I have a look at metaclasses?
You have functions in your code not classes, the parent class is also called
ParentClass
not Advert:You might want to have a read of this tutorial