more python to c/c++ questions.

Gordon McMillan gmcm at hypernet.com
Tue Jun 8 18:18:47 CEST 1999


Jr. King is asking something or other:

> Ok, I found some info on it but, it still doesn't work
> 
> I changed my c module to this...
> <snip>
> static PyObject* objPass(PyObject *self, PyObject* args){
>     PyObject *result = NULL;
>     PyObject *temp;
> 
>     if (PyArg_ParseTuple(args, "O", &temp)) {
>    PyObject* xarg = Py_BuildValue("(s)","i");

You've just built a tuple. Probably not what you want.

>    xarg = PyObject_GetAttr(temp,xarg);  // not getting anything but
>    null int val; PyArg_ParseTuple(xarg,"i",&val);
>  }
>     Py_INCREF(Py_None);
>     result = Py_None;
>     return result;
> }
> 
> Python module snippet
> 
> class Cow:
>  i = 10
>  x = 0
>  str = "string"
>  def genie(self):
>   print str
> 
> testmeth.setCallback(setN)
> testmeth.testmeth(13,9)
> cow = Cow()
> testmeth.objpass(cow);

- Gordon




More information about the Python-list mailing list