Embedded Python - how do I implement a Python class in C++?

Michal Szabelski michalszabelski at o2.pl
Thu Jan 2 19:10:20 EST 2003


Hello. 

I'm embedding Python in C++. I already know how to define modules, 
pass PyCObjects, define my own type with methods by implementing 
getattr and getattro functions (I use PyCFunction_New to make 
objects these functions return). This type is class-like, it has 
methods, and a pointer to C++ class instance. But I'd like to 
implement a full blown, inheritable (and/or inheriting) Python class 
in C++. 
In the includes I found PyClass_New and PyMethod_New, but I can't 
guess what arguments they take (these 3 PyObject pointers). 
In wxPython I found that they use SWIG somehow - I don't know how 
to use it. 
If it makes any difference - I do the embedding under Windows. 

How do I call PyClass_New and PyMethod_New?
Or, alternatively:
How do I use SWIG?

Michal Szabelski 






More information about the Python-list mailing list