[Edu-sig] Re: Please help in calling python fucntion from 'c'

Burley, Brent Burley, Brent" <Brent.Burley@disney.com
Wed, 04 Sep 2002 09:29:49 -0700


Praveen Patil wrote:
> I want to call python function from 'c' function.

The easiest way is this:
PyRun_SimpleString("TestFunction()");

If you need to get return values back or if you want to run the code in other than the "__main__" module, you can use PyRun_String.  If you need to pass in PyObjects to a function instead of just running a string, then you need to use PyObject_CallFunction.

PyRun_String and PyRun_SimpleString are described here:
http://www.python.org/doc/current/api/veryhigh.html

PyObject_CallFunction is described here:
http://www.python.org/doc/current/api/object.html#l2h-179

	Brent