Modes of method inheritance - implicit
Inherit method
class Parent:
def greet(self):
print("Hello World")
class Child(Parent):
pass
p = Parent()
p.greet() # Hello World
c = Child()
c.greet() # Hello World
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
Inherit method
class Parent:
def greet(self):
print("Hello World")
class Child(Parent):
pass
p = Parent()
p.greet() # Hello World
c = Child()
c.greet() # Hello World