Executing a specific function.

Martin v. Loewis martin at v.loewis.de
Fri Mar 29 11:49:46 EST 2002


Michael Saunders <michael at amtec.com> writes:

> I see that the Python C API provides several interfaces for
> compiling and executing Python code. But I don't want to just
> execute some Python code I want to call a particular function within
> a Python file. How do I call a Python function (from C) in a some
> .py file?

It depends on whether you already have a argument tuple, or whether
you have the arguments as C data. In the former case, use
PyObject_Call; in the latter case, use PyObject_CallFunction. Also
notice PyObject_CallMethod.

HTH,
Martin




More information about the Python-list mailing list