X
Xaver Hinterhuber
Hello pythonistas,
I have programmed a product in Zope which allows me to source code on the
web.
Now I want to compile the code into a function and execute the function.
The code is as follows:
import new
code = compile(srcString, 'getContent', 'exec')
f = new.function(code, globalDict, 'getContent')
If srcString contains a return statement, then
python returns a CompilationError stating, that I cannot use return outside
a function.
How do I have to compile the sourcecode to get around this problem?
I have programmed a product in Zope which allows me to source code on the
web.
Now I want to compile the code into a function and execute the function.
The code is as follows:
import new
code = compile(srcString, 'getContent', 'exec')
f = new.function(code, globalDict, 'getContent')
If srcString contains a return statement, then
python returns a CompilationError stating, that I cannot use return outside
a function.
How do I have to compile the sourcecode to get around this problem?