passing callback function to c-extension

Eric Brunel eric.brunel at N0SP4M.com
Wed Jan 14 10:36:18 EST 2004


Diez B. Roggisch wrote:
> Hi,
> 
> I'm currently writing my first c-extension module. First of all: distutils
> and the tutorial for embedding/extending rock! Great work, guys.
> 
> However, I didn't find a hint how to pass a python callback function.
> Googling didn't turn out much useful stuff, so I'd be glad if someone could
> post a hint on how to do this.

A Python function is just a regular Python object, so it is represented at C 
level by a PyObject*. To call it from C, just use one of the PyObject_Call 
functions - see http://www.python.org/doc/current/api/object.html#l2h-189

HTH
-- 
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com




More information about the Python-list mailing list