more python to c/c++ questions.

Jr. King n at
Mon Jun 7 18:01:17 CEST 1999

Can you pass a user defined type in python to a c/c++ program.  I didn't see
this in the docs and I would assume it isn't possible.  I have the questions
commented inside my code

I snipped (=-)) this from my code...
class Cow:
 i = 10
 x = 0
 str = "string"

testmeth.setCallback(setN)  //fine
testmeth.testmeth(13,9)  //fine
cow = Cow()  //fine
testmeth.objpass(cow);   //problem with this and the c code.

static PyObject* objPass(PyObject *self, PyObject* args){
    PyObject *result = NULL;
    PyObject *temp;

    if (PyArg_ParseTuple(args, "O", &temp)) {  /*this works ok*/
                                            /*But how Am I supposed to
parseTuple the arg???*/
        result = Py_None;
    return result;

Do I need to make a C++ class or struct that can map directly to the python
object ?


More information about the Python-list mailing list