Re: question on creating class

2007-01-04 Thread Thomas Heller
wcc schrieb: 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

Re: question on creating class

2007-01-04 Thread Jussi Salmela
wcc kirjoitti: 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

Re: question on creating class

2007-01-04 Thread Steven D'Aprano
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__

Re: question on creating class

2007-01-04 Thread wcc
Thanks for all replies. I'll just to have to figure our which suggested method I should use. To answer Jussi's question, this is why I asked the question. I have the book by Mark: Python Programming on Win32. In Charpter 12: Advanced Python and COM there is a sample code named:

question on creating class

2007-01-03 Thread wcc
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):

Re: question on creating class

2007-01-03 Thread tonisk
You can always rename your defined clas afterwards class TestClass: pass myClass = 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

Re: question on creating class

2007-01-03 Thread tonisk
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