Passing python method's reference to C as callback -
can pass reference of python method argument c. method callback method executed after c code has been executed.
in python c-api, python objects pyobject references. pyobject references can called using pyobject_call (if want have more descriptive errors, can call pycallable_check, first.)
assuming you've extended module using api have method follows:
bool call_method(pyobject *method) { pyobject *args = pytuple_new(0); if ( null == pyobject_call(method, args, null) ) { // method call failed return false; } return true; } then, in python, call method using following:
import my_module bla bla.call_method(myclass.mymethod)
Comments
Post a Comment