import class from string

Mariano DAngelo marianoa.dangelo at
Wed Jul 4 22:27:29 CEST 2012

Hi I'm trying to create a class from a string.... 
This is my code, but is not working....

module_name, class_name = model.rsplit(".", 1)
module = importlib.import_module(module_name)
class_ = getattr(module, class_name)()

Anyone know what I'm doing wrong.... or another way?


More information about the Python-list mailing list