[Tutor] Problems working with the function PyArg_Parse
Jörg Wölke
lumbricus@gmx.net
Fri, 17 May 2002 16:35:30 +0200 (MEST)
> Hi !
>
> I want to convert a python script return value (9,2034) to c. It´s a
> double and it seems that i use the function PyArg_Parse in the the wrong
> way.
> Here' s the code:
>
> ...
> double *cstr;
> PyObject *pmod, *pargs, *pmeth, *pres;
> ...
> pres = PyEval_CallObject(pmeth, pargs);
> Py_DECREF(pmeth);
> Py_DECREF(pargs);
> if (pres == NULL)
> error("Error calling para()");
> if (!PyArg_Parse(pres, "i", &cstr)) /* convert to C */
> error("Can't convert para() result");
> printf("%d\n", cstr);
^^
printf("%f\n", cstr);
> Py_DECREF(pres);
>
> Perhaps anyone can tell me to use the options (pres, "i", &cstr) in the
> right way. I only get a "9" ,but not 9,2034.
>
> Greetings
> Marcus
HTH and Greetings,
J"o!
--
$ make LOVE
Make: Don't know how to make LOVE. Stop.
$
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net