Instantiating a class from its name

Daniel Klein danielk at aracnet.com
Sat Nov 17 15:45:44 EST 2001


I need to create a class factory such that passing the 'name' of the class to the method will
produce an instance of that class. In Java, you do this with

	Class c = Class.forName("name_of_class");
	MyClass m = c.newInstance();

What is the Python equivalent?

Thanks,
Daniel Klein




More information about the Python-list mailing list