My question is a bit more complicated as the question described here.
So assuming we have two Superclasses, how can i istantiate the subclass depending on the superclass i passed?
class ASuperClass:
def __init__(self, tediously, many, attributes):
# assign the attributes like "self.attr = attr"
class BSuperClass:
def __init__(self, tediously, many, attributes):
# assign the attributes like "self.attr = attr"
What i tried is:
class SubClass(ASuperClass, BSuperClass):
def __init__(self, id, a_super_class_instance, b_super_class_instance):
self.id = id
if a_super_class_instance:
ASuperClass().__init__(**a_super_class_instance)
elif:
ASuperClass().__init__(**b_super_class_instance)
else:
raise ValueError("At least one of the superclasses have to be passed.")
However, this did not work. My wish is depending on the input, i get the subclass with the params as output.
s1 = SubClass(id, ASubClass)
s2 = SubClass(id, BSubClass)