How to set class names dynamically?
<p>I have a function that creates classes derived from it's arguments:</p>

<pre><code>def factory(BaseClass) :
    class NewClass(BaseClass) : pass
    return NewClass
</code></pre>

<p>Now when I use it to create new classes, the classes are all named the same, and the instances look like they have the same type:</p>

<pre><code>NewA = factory(ClassA)
NewB = factory(ClassB)
print type(NewA()) # &lt;class __main__.NewClass&gt;
print type(NewB()) # &lt;class __main__.NewClass&gt;
</code></pre>

<p>Is the proper fix to manually set the <code>__name__</code> attribute?</p>

<pre><code>NewA.__name__ = 'NewA'
print type(NewA()) # &lt;class __main__.NewA&gt;
</code></pre>

<p>Are there any other things I should be setting while I'm at it?</p>

<p>Thanks in advance.</p>
