On Nov 16, 7:11 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Borse, Ganesh" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | Py_CompileString takes the sourcecodefrom file, isn't it? > > No. > > | As can be seen from the syntax of thisfunction: "PyObject* > Py_CompileString(char *str, char *filename, int start)" > > I am rather sure that the filename param is the same as for the > Python-level builtinfunctioncompile: > compile( string, filename, kind[, flags[, dont_inherit]]) > > Compile the string into acodeobject.Codeobjects can be executed by an > exec statement or evaluated by acallto eval(). The filename argument > should give the file from which thecodewas read; pass some recognizable > value if it wasn't read from a file ('<string>' is commonly used). > > The filename is used for exception traceback messages.
Hi, I want to put this code in a function & call it. I am now facing a problem that, I am able to compile a function using Py_CompileString. That generates a "*definition*" of that function. I am stuck at a road block & not able to execute this function definition which is part of "*codeObject*" returned by Py_CompileString. What should I do to transform this 'code' object to 'callable' or 'function' object, so that I can call it? Please help. Regards. -- http://mail.python.org/mailman/listinfo/python-list