[EMAIL PROTECTED] wrote:
...
> exec testModule.TheTestCode %(testModule.TheTestName, testModule.TheTestName )
...
Try changing that to exec ~ in testModule.__dict__
otherwise, your class statement gets executed in the current scope
Michael
--
http://mail.python.org/mailman/listinfo/python-lis
Oh! I see what I missed. I didn't supply the namespace into which the
new class was going to be added (correct that statement, please, if it
is incorrect).
So by using this slight modification, thinks seemed to work:
exec testModule.TheTestCode %(testModule.TheTestName,
testModule.TheTestName )
Hi Michael... It didn't seem to take. Here is some of the actual code:
[[ from the runner ]
print "+++"
print "::Dir before exec:",dir(testModule)
import CodeGenBase
[EMAIL PROTECTED] writes:
> So: Does anyone know how dynamically generate a class, and add it to a
> "module" that is already in memory?
How about adding a step:
generate your class to a file
import the file as a module.
bind a name in "module" to the class in the imported module.
[EMAIL PROTECTED] wrote:
> I'm trying to add a class to a module at runtime. I've seen examples
> of adding a method to a class, but I haven't been able to suit it to my
> needs.
>
> As part of a testsuite, I have a main process X that searches
> recursively for python test files. Those files ty
I'm trying to add a class to a module at runtime. I've seen examples
of adding a method to a class, but I haven't been able to suit it to my
needs.
As part of a testsuite, I have a main process X that searches
recursively for python test files. Those files typically have a global
"isSupported" m