I do apologize if this question is already answered on SO or if my problem could be solved by a simple Google search, but I don't know the terminology to describe it, other than the question title, which didn't turn up any results.
Because I don't know the terminology, the best I can do is give an example of what I want.
class MyClassProperty():
def __init__(self):
# somehow access MyObject class
pass
class MyObject():
var = MyClassProperty()
MyClassProperty will not only need to reference the MyObject class, otherwise it would be simple. The end goal is to be able to automatically add methods and variables to the MyObject class when a MyClassProperty is instantiated at class level.
I have seen frameworks and libraries do this before, the one that first comes to mind is Kivy, with its properties.
Thanks for any help you can give, even if the extent of that help is to tell me this is impossible.
MyObjector you actually want to act on an instance ofMyObjectinside MyClassPropertyMyClassPropertyis used as a class variable forMyObject. I could act on an instance if that is easier, but I would want to act on all instances. I thought it would be easier to add methods and variables to theMyObjectclass that would be automatically added to instancesMyClassPropertyinits, inspect the stacktrace and addMyObjectto an internal list of objects instantiatingMyClassProperty, but it is ugly. Explicit is better than implicit... Why not just use the "mixin" pattern?