Problem
I came across this code in Object Oriented Programming by Dusty Phillips (simplified for brevity) and I unsure about a specific part of this definition.
class A:
def __init__(self, a, **kwargs):
super().__init__(**kwargs)
self.a = a
class B:
def __init__(self, b, **kwargs):
super().__init__(**kwargs)
self.b = b
class C(A, B):
def __init__(self, c, **kwargs):
super().__init__(**kwargs)
self.c = c
Questions
- Since the method resolution order is
(__main__.C, __main__.A, __main__.B, object), couldclass Bbe defined in the following way instead?
class B:
def __init__(self, b):
self.b = b
- Isn't
super().__init__(**kwargs)inclass Bredundant, since any surpluskwargspassed toCwill be passed toobject, raising?
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
- Is this a safeguard for if
Cwas defined asclass C(B, A)instead ofclass C(A, B)?