Get python class object from string
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/301134/dynamic-module-import-in-python">Dynamic module import in Python</a>  </p>
</blockquote>



<p>Probably a simple question! I need to iterate through a list of classes (as strings) passed from a settings file. The classes are listed like below:</p>

<pre><code>TWO_FACTOR_BACKENDS = (
    'id.backends.AllowToBeDisabled', # Disable this to enforce Two Factor Authentication
    'id.backends.TOTPBackend',
    'id.backends.HOTPBackend',
    #'id.backends.YubikeyBackend',
    #'id.backends.OneTimePadBackend',
    #'id.backends.EmailBackend',
)
</code></pre>

<p>I now need to call the <code>authenticate()</code> function on each of these classes (unless commented out, of course). I'm happily iterating through the list, I just need to know how to convert the strings to a Class object in my foreach loop so that I can call the <code>authenticate</code> method on it. Is there an easy way to do this?</p>
