Reputation: 15
class Test:
alive = True
def __init__(self,name,age):
self.name = name
self.age = age
def calling(self):
return f'hello!! {self.name}. You are {self.age}. Are you alive {self.alive}'
class Test_child(Test):
pass
test1 = Test('Paul',19)
child1 = Test_child('John',27)
child1.calling()
child1.name = 'Adam'
child1.calling()
why my program executes only the last calling method from class. why not both of it ?
Upvotes: 0
Views: 32
Reputation: 124
It's not that only the last method has been called. I think that there are print statements missing. For example :
child1.calling()
into
print(child1.calling())
I think that u have this prob, since you execute your code in jupyter notebook or google collab, isnt it?
Upvotes: 1