python dynamic class names
<p>Trying to instantiate a class based on a string value and... failing. The <code>parser</code> object below is a <code>dict</code>, in the example let's say we have one called <code>foo</code> and here <code>parser['name']</code> is 'foo':</p>

<pre><code>obj = parser['name']()
</code></pre>

<p>Fails, yielding <code>TypeError: 'str' object is not callable</code>. But, since I have:</p>

<pre><code>class foo:
    def __init__(self():
        print 'Hello'
</code></pre>

<p>And if I do <code>obj = foo()</code> it works fine and creates the correct object. Also, calling <code>obj = type(parser['name'])()</code> doesn't work.</p>

<p>How to resolve this? <strong>Update:</strong> I don't really want to use a mapping system: the names of these classes are defined INI files, and parsed that way, so they will be strings..</p>
