title: Is there a way to call a function after a class was loaded in python?
body: <p>I want to register classes to a manager after class was loaded, like http handlers register to a handler manager.</p>
  
  <p>It can be done in other ways, such as define the relationship in a map or call a register function after class definition.</p>
  
  <p>But is there a better way to do this automatically?</p>
  
  <hr>
  
  <p>update:</p>
  
  <p>While Dunes's answer filled my need. I'm trying to improve the question and make it more useful for others who meet the same problem.</p>
  
  <p>Here are the examples.</p>
  
  <p>handler/__init__.py</p>
  
  <p>handler/basehandler.py - classBase, HandlerManager</p>
  
  <p>handler/handlerA.py - classA(classBase)</p>
  
  <p>handler/hanlderB.py - classB(classBase)</p>
  
  <p>handlerA and handlerB contains classA and classB, which are subclasses of classBase.</p>
  
  <p>classA handlers requests from /a/, classB handlers /b/</p>
  
  <p>I need to register them to HandlerManager automatically at the first time the handler module is imported.</p>