title: Python: How to register all child classes with the father class upon creation
body: <p>I have python class trees, each made up of an abstract base class and many deriving concrete classes. I want all concrete classes to be accessible through a base-class method, and I do not want to specify anything during child-class creation.</p>
  
  <p>This is what my imagined solution looks like:</p>
  
  <pre><code>class BaseClassA(object):
      # &lt;some magic code around here&gt;
      @classmethod
      def getConcreteClasses(cls):
          # &lt;some magic related code here&gt;
  
  class ConcreteClassA1(BaseClassA):
      # no magic-related code here
  
  class ConcreteClassA2(BaseClassA):
      # no magic-related code here
  </code></pre>
  
  <p>As much as possible, I'd prefer to write the "magic" once as a sort of design pattern. I want to be able to apply it to different class trees in different scenarios (i.e. add a similar tree with "BaseClassB" and its concrete classes).</p>
  
  <p>Thanks Internet!</p>