Inheritance in Python

Inheritance in Python

Let's imagine that we have a python class as follows (Python 3):

class MyClass:
	def init(self):
	# Code of the class constructor...
	print("Instance of MyClass created")

A child class of MyClass can be created as such:

class MyChildClass(MyClass):
	def init(self):
	    super().init__() # calls constructor of MyClass
	    print("Instance of MyChildClass created")

By creating an instance of MyChildClass, Instance of MyClass created and Instance of MyChildClass created should be printed in the console.