I am confused about the convention of passing *args in super().__init__() in python inheritance.
I understand the need to use keyword arguments **kwargs so the required arguments can be taken by the class in CRO if needed, but why there's also a *args?
Example: Suppose Sneaky is used as part of a multiple inheritance class structure such as:
class Sneaky:
def __init__(self, sneaky = false, *args, **kwargs):
super().__init__(*args, **kwargs)
self.sneaky = sneaky
class Person:
def __init__(self, human = false, *args, **kwargs):
super().__init__(*args, **kwargs)
self.human = human
class Thief(Sneaky, Person):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
t = Thief(human = true, sneaky = true)
print(t.human)
# True
So what if we have below instead aka remove the *args?
class Sneaky:
def __init__(self, sneaky = false, **kwargs):
super().__init__( **kwargs)
self.sneaky = sneaky
class Person:
def __init__(self, human = false, **kwargs):
super().__init__(**kwargs)
self.human = human
class Thief(Sneaky, Person):
def __init__(self, **kwargs):
super().__init__( **kwargs)
t = Thief(human = true, sneaky = true)
print(t.human)
# True