The super method in python.
In this video, I am going to introduce the super method (also called super function) in python and how can you use it to organize your code and get rid of duplicate code lines when using classes in python. The super method allows subclasses (also called child classes) to access methods from superclasses ( also called parent classes). It is very easy to use and can save your time and simplify your code. Now, enjoy the video.
The code :
class student:
def __init__(self , name , id):
self.name = name
self.id =id
def basic_info(self):
print('name :' , self.name , '\t id : ' , self.id)
def print_id(self):
print('Id : ' , self.id)
class scholarship(student):
def __init__(self , name , id):
super().__init__(name , id)
class selfexpense(student):
def __init__(self, name, id , tuition , payment):
super().__init__(name , id)
self.tuition = tuition
self.payment = payment
Tom = scholarship(" Tom" , 209)
Tom.basic_info()
Ali = selfexpense("Ali" , 210 , 10000 , 2000)
Ali.basic_info()
Ali.print_id()
Auf dieser Seite können Sie das Online-Video super method in python explained with an example mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer khalil alkebsi 28 September 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 171 Mal angesehen und es wurde von 14 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!