On Feb 26, 5:43 pm, Venky <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am trying to create classes at runtime based on input from a textfile.
> I am trying to use the function new.classobj. I am able to create the
> new classes successfully, however I fail to understand on how to add
> this new class to the current dictionary.
>
> cl = new.classobj('SomeClass', (BaseClass, ), {})
>
> After this call, how do I instantiate SomeClass?
>
> I understand cl() will instantiate this, however this defeats my
> purpose, since the name of the class is obtained at runtime.
>Do you mean that you want to add it to globals()? globals()['SomeClass'] = cl myinst = SomeClass() print isinstance(myinst, SomeClass) print isinstance(myinst, BaseClass) -- Hope this helps, Steven -- http://mail.python.org/mailman/listinfo/python-list
