title: Python: Constructing a multiple-inheritance subclass instance from a superclass
body: <p>So I have in my project two classes: <code>Circuit</code> and <code>SubCircuit</code>. At some point I may need to construct a <code>SubCircuit</code> from a <code>Circuit</code>. Is there a more elegant way to do that than what's done below in the last 4 lines? <code>Circuit</code> may get some new attributes at some point for example, which would mean that conversion would also need to be updated - basically inviting bugs.</p>
  
  <pre><code>class Gate(abc.ABC):
      def __init__(self, size):
          self.in_ports = (InPort(self),) * size
          self.out_ports = (OutPort(self),) * size
  
  
  class Circuit:
      def __init__(self, size):
          self.input = (OutPort(self),) * size
          self.output = (InPort(self),) * size
          self.gates = []
  
      # ... some other stuff that messes around with these attributes
  
  
  class SubCircuit(Gate, Circuit):
      def __init__(self, circuit=None):
          Gate.__init__(self, size)
          Circuit.__init__(self, size)
  
          if circuit is not None:
              self.gates = circuit.gates
              self.input = circuit.input
              self.output = circuit.output
  </code></pre>