title: Dynamic inheritance in Python
body: <p>Say I have 2 different implementations of a class</p>
  
  <pre><code>class ParentA:
      def initialize(self):
          pass
  
      def some_event(self):
          pass
  
      def order(self, value):
          # handle order in some way for Parent A
  
  
  class ParentB:
      def initialize(self):
          pass
  
      def some_event(self):
          pass
  
      def order(self, value):
          # handle order in another for Parent B
  </code></pre>
  
  <p>How can I dynamically let some 3rd class inherit from either <code>ParentA</code> or <code>ParentB</code> based on something like this?</p>
  
  <pre><code>class MyCode:
      def initialize(self):
          self.initial_value = 1
  
      def some_event(self):
          # handle event
          order(self.initial_value)
  
  
  # let MyCode inherit from ParentA and run
  run(my_code, ParentA)
  </code></pre>