Registering a python function in C

Hrvoje Niksic hniksic at xemacs.org
Fri Aug 31 07:06:00 EDT 2007


fernando <fernandofariajunior at gmail.com> writes:

> Could someone post an example on how to register a python function as
> a callback in a C function?

If I understand correctly, your C function receives a Python function
(as a function object of type PyObject *), which you need to call from
C.  To do that, call PyObject_CallFunction(obj, format, args...) where
format and args are documented in
http://docs.python.org/api/arg-parsing.html.

Does that help?

Also note that there is a dedicated mailing list for the Python/C
API; see http://mail.python.org/mailman/listinfo/capi-sig .



More information about the Python-list mailing list