[C++-sig] Using a phython function as callback

jochen jochen at neverEngine.com
Tue Jun 24 20:58:22 CEST 2003


Hello everybody.

I have a class

class Selectable
{
	...
};

which I exported to be part of my python module.


Now I wrote a Python function:

def UpdateSelectedObject( i_Selectable ):

	# do something with the Selectable instance.
	return

I got access to the function via the dict of my module.
Now I wan't to use PyObject_CallObject() to call the function.
But how do I pass a instance of type Selectable to the function.

Passing a integer or string is easy, because there a functions available
from the PythonAPI.
But how do I wrap my instance of type Selectable into a PyObject ?

Can I use part of the boost api do this, I mean this is exactly what boost
does, isn't it.

Can anybody help a bloody beginner ?





More information about the Cplusplus-sig mailing list