I have created a class Character
and a subclass Player
. I want to create an instance of the Player
subclass but specify the self.variables during instantiation.
class Character():
def __init__(self):
self.ID = None
self.Name = None
self.Colour = None
class Player(Character):
def __init__(self, ID, Name, Colour):
self.ID = ID
self.Name = Name
self.Colour = Colour
self.Karma = 0
self.Charisma = 0
self.Strength = 0
self.Intelligence = 0
I can easily create an instance by using Player("tutorial_guy", "Tutorial Ted", "Green")
but then that defeats the whole point of a subclass because of how the subclass Player
is set up. How would I make the variables of ID
, Name
and Colour
be set in Character
but still instantiated the same way?