In my code, I generate new python classes at runtime. For some of them, I want to generate the python code, just as if I wrote these classes in a .py file.
Let's say that I created dynamically a class A:
type('A', (), {'bar':True} which is equivalent to the code:
class A(object):
bar=True
What I want is to generate this equivalent code from my dynamic class. I'm trying to implement a function "generate_A_code"
kls_A = type('A', (), {'bar':True}
kls_A.generate_A_code()
Hope this helps a bit.
Thanks
.pyfile, nor do you generate the code as a string andevalit... so what it is that you do exactly?