I have python class trees, each of which consists of an abstract base class and many, invoking specific classes. I want all concrete classes to be accessible through a base class method, and I don't want to specify anything while creating a child class.
Here's what my imaginary solution looks like:
class BaseClassA(object): # <some magic code around here> @classmethod def getConcreteClasses(cls): # <some magic related code here> class ConcreteClassA1(BaseClassA): # no magic-related code here class ConcreteClassA2(BaseClassA): # no magic-related code here
As much as possible, I would rather write βmagicβ once as a kind of design pattern. I want to be able to apply it to different class trees in different scenarios (for example, add a similar tree with "BaseClassB" and its specific classes).
Thank you internet!
source share