Problem Calling Python callbacks from C
Tim Egbert
tegbert at abl.med.utah.edu
Tue Apr 2 12:50:24 EST 2002
I'm able to call a Python callback _function_ from C code by following the
information in "Extending and Embedding the Python Interpreter," section
1.6, but I can't get the callback to work if I'm calling a Python object
_method_. Does anyone know how to do that?
In other words, it works if I'm using a Python function such as:
def callback_func(i):
print i
and I set "callback_func" as the callback but not if the callback is an
object method such as:
class callbackClass:
def callback_method(self,i):
print i
cbc=callbackClass()
and I set the callback as "cbc.callback_method".
I'm using the "PyEval_CallObject(callback,arglist)" function in my C code
to make the callback. I assume the problem has to do with not having the
"self" argument available in the arglist for the callback method, but I
haven't been able to find any documentation on how to provide "self" or
what Python function to use for calling an object method.
Tim
More information about the Python-list
mailing list