Can you create a class from a string name

Brian Quinlan brian at sweetapp.com
Fri Feb 28 16:58:22 EST 2003


> is there a way to create a class object or an instance object for a
> class if you have the name of the class as a string at the runtime.
> 
> For example, in Java you can create a 'Class' object as:
> 
> Class.forname ('<classname>')

class = eval('<classname>')
instance = eval('<classname>')(<constructor_args>)

Cheers,
Brian






More information about the Python-list mailing list