Python: inspecting module to pick out classes of certain type?
<p>I have a module where all classes that implement my "policies" are defined. </p>

<pre><code>class Policy_Something(Policy_Base):
    slug='policy-something'
    ...

class Policy_Something_Else(Policy_Base):
    slug='policy-something-else'
    ...
</code></pre>

<p>I need to create a mapping from slug to class. Something like:</p>

<pre><code>slug_to_class = {
    'policy-something': Policy_Something,
    'policy-something-else': Policy_Something_Else
}
</code></pre>

<p>I was thinking instead of automatically creating slug_to_class by inspecting the module and looking for classes that inherit from Policy_Base (similar to how unittest finds tests, I assume).</p>

<p>Any reason I shouldn't do that? If not, how exactly would I do that?</p>
