I was reading on method overriding and in other languages, it seems that to be completely overridden, the method has to have the same signature (parameters, return type... etc)
so I was trying to check if that's how it worked with python and I tried the next code
class Person():
def __init__(self, name, age):
self.name = name
self.age = age
def print_name(self, last_name):
print(self.name + " " + last_name)
class Superhero(Person):
def __init__(self, name, age, power):
super().__init__(name, age)
self.power = power
def print_name(self):
print(self.name)
human = Person("Ron", 23)
super_human = Superhero("Superman", 30, "Flying")
human.print_name("Wesley")
super_human.print_name("Kent")
and I'm receiving an error on the super_human.print_name("Kent")
part that it takes one argument but I'm passing two, I know the MRO exist in python where I look into (object > class > parent class), so I'm wondering if there's a way that I can call the print_name()
function that exist in the parent class not the current one, since they take different parameters.