title: How do I implement run time objects (different) implementation with using Python
body: <p>My requirement is that I have a  standard framework of generating HTML To PDF in 3 steps : </p>
  
  <p>1)Get stuff from our DB and create a meaning out of it , read XML and over-ride or decided settings etc - <strong>pre_processing</strong></p>
  
  <p>2)Creating an HTML Template using the preprocesed data - <strong>render_template</strong></p>
  
  <p>3)Run a a HTML to PDF Converted and get the PDF back . - <strong>invoke_service</strong></p>
  
  <p>Now , its possible that sometimes different PDF engines might be needed and implementations can change ... Its even possible some of them need a very strict data or proprietary settings </p>
  
  <p>So I might need to <strong>extend 1</strong> , <strong>over-ride 2</strong> , <strong>over-ride 3</strong> and I would like to make this implementation configurable and get switchable easily . </p>
  
  <p>I am thinking of creating a Base Class and then creating Foo.py implementation anf Bar.py implementation that are actually going to be the runtime objects . How can I get this with simple Python ? </p>
  
  <p>A terrible way I can think of is: </p>
  
  <pre><code>#Module Name ServiceHandler
  
  def implementation(imp_name):
      try:
         from imp_name import imp_class
         return imp_class(AbtractClass) 
      else:
         Sorry No Implemenation Found!
  
  class AbstractClass(...)
        def __init__
  
  
  
  Gets invoked in another object method as 
  
  
  self.ServiceHandler.implementation(read_from_xml)
  </code></pre>
  
  <p>Can anyone give me good pointers to solve this problem ? Basically I want Foo(Base) or Bar(Base) and this should be like read a configuration and map it to that . </p>
  
  <p>My current module layout is :</p>
  
  <p>module.py</p>
  
  <ul>
  <li>base.py   </li>
  <li>foo.py   </li>
  <li>bar.py   </li>
  <li>unknown.py should be easily extendable .</li>
  </ul>