Python method callbacks

kFactor kfactor at my-deja.com
Mon Sep 18 22:27:25 EDT 2000


Hi all

I'm trying to store and later call from C++ a reference to a method
from a python class instance using the PyEval_CallObject(...) function.
Am I correct in assuming that method objects are already bound to the
specific instance of the python class? i.e. the self argument is
supplied by python automatically when I call the method (via C++)?

The reason I'm asking this is because when I constructed the argument
list with :

arglist = Py_BuildValue("(O)", Self);
result = PyEval_CallObject(PythonCallback, arglist);

where Self is the "self" object of the instance of the class
Python reported :
TypeError: too many arguments; expected 1, got 2

but when I used :
arglist Py_BuildValue("()");

It worked ok.

Thanks In advance.
Kostas


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list