February 2006
Intermediate to advanced
648 pages
14h 53m
English
Sometimes it’s useful to call Python functions from C programs. To do this, the following functions can be used:
PyObject *PyEval_CallObject(PyObject *func, PyObject *args)
Calls func with arguments args. func is a Python callable object (function, method, class, and so on). args is a tuple of arguments.
PyObject *PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
Calls func with positional arguments args and keyword arguments kwargs. func is a callable object, args is a tuple, and kwargs is a dictionary.
The following example illustrates the use of these functions:
/* Call a python function */ PyObject *func; /* Callable object. */ PyObject *args; PyObject *result; int arg1, arg2; func = ...