On Wed, 03 Jan 2007 23:27:57 -0800, wcc wrote: > Hello, > > How do I create a class using a variable as the class name?
Try a "class factory". def create_class(classname): class Klass(object): def __init__(self): print "Creating object of %s..." % self.__class__.__name__ def method(self): print "This is a method." k = Klass k.__name__ = classname return k >>> K = create_class("TestClass") >>> obj = K() Creating object of TestClass... -- Steven. -- http://mail.python.org/mailman/listinfo/python-list