Or if you have required class name in variable, then use:
class TestClass:
pass
globals()[className] = TestClass
--
Tõnis
On Jan 4, 9:27 am, "wcc" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> How do I create a class using a variable as the class name?
>
> For example, in the code below, I'd like replace the line
>
> class TestClass(object):
> with something like
> class eval(className) (object):
>
> Is it possible? Thanks for your help.
>
> className = "TestClass"
>
> class TestClass(object):
> def __init__(self):
> print "Creating object of TestClass..."
>
> def method1(self):
> print "This is a method."
>
> if __name__ == "__main__":
> o = TestClass()
> o.method1()
>
> --
> wcc
--
http://mail.python.org/mailman/listinfo/python-list