This code creates a base class and then defines two more classes that inherit from the base class. We now can find all classes that have inherited from the main class by calling the base class built-in method__subclasses__(). This is a very powerful mechanism for finding classes without knowing their names, or even the names of the module from which they have been loaded.
Once the classes have been discovered, we can create the instances of each class and add them to a list. This is the registration process. After all the objects have been registered, the main program can start calling their methods:
Was this article helpful?