exec a string in an embedded environment

Tommy R Tommy.Ryding at gmail.com
Wed Jan 11 07:29:32 EST 2006

Hi all pythonistas!

I have a problem with my embedding of python inside a c app.

very short background
I work on a safety critical embedded application that runs on VxWorks.
I have successfully ported the interpreter to VW. In my solution I have
restricted other "classes" to use python through my simplified api. Its
a really complex architecture that force me to work this way, I have
encapsulated the entire interpreter with its own memspace and so on.
Redirected all IO signals and such.

To the problem
I need some way to execute a string and pass arguments to the functions
inside the string. We have discussed a solution where we first load the
string (containing some funcs) and then run something similar to
Py_RunString("foo(1.0, 'str')");  We need to do this in a generic way
so we can send in arbitrary arguments.

Can I use Py_CompileString to get a PyObject to that 'module' and then
in some magic way call a function within that module?

I am totaly out of ideas so please help me anyone.


More information about the Python-list mailing list