How to tell if a class is descended from another class
<p>I have a function that accepts a class (not an instance) and, depending on whether or not it's a specific class <em>or a subclass of that</em>, I need to pass it in to one of two other (third-party) factory functions.</p>

<p>(To forestall any objections, I'm aware this is not very Pythonic, but I'm dependent on what the third-party library accepts.)</p>

<p><code>issubclass</code> only works for instances, not class objects themselves. I suppose I could instantiate the class, do <code>issubclass</code> and throw away the instance, but that seems a bit wasteful.</p>

<p>Here's what I'm doing at the moment, relying on the built-in <strong>mro</strong> attribute to tell if a certain class is in the list of ancestors of my class. Is this safe, and is there any better way of doing it?</p>

<pre><code>if GenericClass in myclass.__mro__:
    result = generic_factory(myclass)
else:
    result = other_factory(myclass)
</code></pre>
