Extending Python and Callbacks..

Martin von Loewis loewis at informatik.hu-berlin.de
Thu May 24 11:48:13 EDT 2001


"John" <john.thai at dspfactory.com> writes:

>     Is there a way to pass a python call back function to a C extension
> module function?

Certainly. Just pass it as an argument. If you use PyArg_ParseTuple,
you need to specify an O converter, and perform PyCallable_Check
yourself afterwards.

When you are ready to invoke the callback, you use
PyObject_CallFunction (or PyObject_CallObject if you have the
arguments already as a tuple).

Regards,
Martin

P.S. As a general note: Everything that you write in Python can be
done from a C extension as well.



More information about the Python-list mailing list