class A: def function(self): print("function() method from class A") class B(A): def function(self): print("function() method from class B") b_obj = B() a_obj = A() b_obj.function() a_obj.function()