Python's Multiple Inheritance: Picking which super() to call
Solution 1:
That's not what super()
is for. Super basically picks one (or all) of its parents in a specific order. If you only want to call a single parent's method, do this
class ASDF(ASDF1, ASDF2, ASDF3):
def __init__(self):
ASDF2.__init__(self)
Solution 2:
super
calls the next method in the method resolution order. In a linear inheritance tree, that will be method from the immediately parent class.
Here, you have three parents, and the next __init__
method from ASDF1
's perspective is that of ASDF2
. In general, the safe thing to do is to pass the first class in the inheritance list to super
unless you know why you want to do something else.
The point of all of this is to relieve you of having to explicitly pick which __init__
methods to call. The question here is why you don't want to call all of the superclass __init__
methods.
There's a fairly substantial literature on the use of super
in python, and I recommend that you google the topic, and read what results.