Possible Duplicate:
Dynamic module import in Python
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:
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',
)
I now need to call the authenticate() 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 authenticate method on it. Is there an easy way to do this?
authenticate()called on the classes, or on objects of those classes?authenticate()is called on the classes, not the objects of the classes. Should have made that more clear sorry!