I am following a tutorial online and the code is this:
class Hands(list):
def __init__(self, size=0, die_class=None, *args, **kwargs):
if not die_class:
raise ValueError("You must provide a die class")
super().__init__()
for _ in range(size):
self.append(die_class())
It basically models a player with a number of dice (size
) and what dice they are holding (die_class
).
My confusion is why do we need to call super().__init__
? I tried running the code without it and it worked fine! Why is the call necessary?