Python super class reflection
<p>If I have Python code</p>

<pre><code>class A():
    pass
class B():
    pass
class C(A, B):
    pass
</code></pre>

<p>and I have class <code>C</code>, is there a way to iterate through it's super classed (<code>A</code> and <code>B</code>)? Something like pseudocode:</p>

<pre><code>&gt;&gt;&gt; magicGetSuperClasses(C)
(&lt;type 'A'&gt;, &lt;type 'B'&gt;)
</code></pre>

<p>One solution seems to be <a href="http://docs.python.org/lib/module-inspect.html">inspect module</a> and <code>getclasstree</code> function.</p>

<pre><code>def magicGetSuperClasses(cls):
    return [o[0] for o in inspect.getclasstree([cls]) if type(o[0]) == type]
</code></pre>

<p>but is this a "Pythonian" way to achieve the goal?</p>

<p><code>C.__bases__</code> is an array of the super classes, so you could implement your hypothetical function like so:</p>

<pre><code>def magicGetSuperClasses(cls):
  return cls.__bases__
</code></pre>

<p>But I imagine it would be easier to just reference <code>cls.__bases__</code> directly in most cases.</p>
