title: python - register all subclasses
body: <p>I have a <code>class Step</code>, which I want to derive by many sub-classes. I want every class deriving from <code>Step</code> to be "registered" by a name I choose for it (not the class's name), so I can later call <code>Step.getStepTypeByName()</code>.</p>
  
  <p>Something like this, only working :):</p>
  
  <pre><code>class Step(object):
      _STEPS_BY_NAME = {}
  
      @staticmethod
      def REGISTER(cls, name):
          _STEPS_BY_NAME[name] = cls
  
  class Derive1(Step):
      REGISTER(Derive1, "CustomDerive1Name")
      ...
  
  class Derive2(Step):
      REGISTER(Derive2, "CustomDerive2Name")
      ...
  </code></pre>