I need class with possibility of create other class instances and self instances in class method scope. I have following code:
class A:
#somme stuff
class B:
allowed_children_types = [ #no reason to make self.allowed_children_types
A,
C #first problem, no C know
]
@staticmethod
def foo(self):
#use allowed_children_types to create children objects
class C:
allowed_children_types = [ # no reason to make self.allowed_children_types
A,
B
C # second problem, no C know because type object is not yet created
]
@staticmethod
def foo(self):
#use allowed_children_types to create children objects
I will not create independent factory because it will complicated very simple application logic. I feel that create custom metaclass is usually bad designe.
What should I do to jump over this issue?
classmethod?