title: Resolving metaclass conflicts
body: <p>I need to create a class that uses a different base class depending on some condition. With some classes I get the infamous:</p>
  
  <pre><code>TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
  </code></pre>
  
  <p>One example is <code>sqlite3</code>, here is a short example you can even use in the interpreter:</p>
  
  <pre class="lang-none prettyprint-override"><code>&gt;&gt;&gt; import sqlite3
  &gt;&gt;&gt; x = type('x', (sqlite3,), {})
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
  </code></pre>