I am aware of this question. Mine is similar, but not the same, because I overwrite said method. And I cannot use @staticmethod
because I will need to use it on self
as well in other functions of the class.
I have class Player
and class Dealer
. In Player
I define a method called print_cards
. In class Dealer
I overwrite this method. How can I get a Dealer instance to use the Player
's print_cards
method and not its own?
class Player():
def print_cards(self):
print('I am in Player\'s class.')
class Dealer(Player):
def print_cards(self):
print('I am in Dealer\'s class.')
p = Player()
d = Dealer()
p.print_cards()
d.print_cards()
d.Player.print_cards() # this is what I am thinking, but it is not valid python
>>> I am in Player's class.
>>> I am in Dealer's class.