I am interested in creating a class hierarchy where various mixins create the slots in an object:
class A(object, Keyable, Taggable):
"""A is keyable and taggable."""
def __init__(self):
super(A, self).__init__()
print "A"
class B(BodyText, Valuable):
"""B is everything a A is, plus Valuable"""
def __init__(self):
super(B, self).__init__()
print "B"
class C(BodyKey, Posable):
"""C is everything a B is, plus Posable"""
def __init__(self):
super(C, self).__init__()
print "C"
However, when I attempt to run this code (along with the mixins below) I get the error """ Cannot create a consistent method resolution order (MRO) for bases Keyable, Taggable, object """
If there is a different way to achieve my goals (such as composition or whatever) I am open to it.
# BEGIN MIXINS
class Posable(object):
def __init__(self):
super(Posable, self).__init__()
self.pos = 0
print "POSABLE"
class Keyable(object):
def __init__(self):
super(Keyable, self).__init__()
self.key = ''
print "KEYABLE"
class Taggable(object):
def __init__(self):
super(Taggable, self).__init__()
self.tag = ''
print "TAGGABLE"
class Valuable(object):
def __init__(self):
super(Valuable, self).__init__()
self.val = 0
print "VALUABLE"
# END MIXINS