Hi, I know this is not a python list, but I hope someone will be able to help me. I have a c library implementing some functions. I have written a python module as a wrapper for this library. What I want to know is that if you have a C function like this: int Hello (char *somestring, int *someint) it now seems that python can get only the value sentback by return??? How can I send back to python changes in someint and somestring? Thank you -- ~~~~~~~~~~~~~~ Alwyn Schoeman Systems Engineer Prism Secure Solutions
What I want to know is that if you have a C function like this: int Hello (char *somestring, int *someint) it now seems that python can get only the value sentback by return??? How can I send back to python changes in someint and somestring?
You can't, just as if you have a python function you have to return the changed objects: def Hello(somestring, someint): ... return (somestring_changed, someint_changed) you have to do the same from C, e.g., return Py_BuildValue("s#", newstring, newint) All of your Python callable functions need to return a PyObject * referring to a Python object (or 0 to indicate an exception has been raised). -=-=-=-=-=-=-=-= Clarence Gardner Software Engineer NetLojix Communications, Inc. NASDAQ:NETX clarence@netlojix.com
On Wed, 1 Dec 1999, Alwyn Schoeman wrote:
What I want to know is that if you have a C function like this: int Hello (char *somestring, int *someint) it now seems that python can get only the value sentback by return???
Why don't you return python objects from you C function. Something like: return Py_BuildValue("ff",x,y); will return two floats, x and y as standard python float objects. Pavlos
participants (3)
-
Alwyn Schoeman -
Clarence Gardner -
Pavlos Christoforou