Hi I have witten C code which call a function defined in python, passing an structure, but couldn't know how to pass c structure into a python function(data conversion) and how to write python script function which takes an c structure and fill value into it (commented portion)
I have looked at struct module but couldn't understand that how it works for below. typedef struct employee { char emp_name[10]; int emp_ID; }emp; int main() { emp e = {0}; Pyobject *pName, *pModule, *pFunc, *pArgs,*pValue; Py_Initialize(); pName = PyString_FromString("test"); pModule = PyImport_Import(pName); Py_DECREF(pName); if (pModule != NULL) { pFunc = PyObject_GetAttrString(pModule, "testStruct"); if(pFunc && PyCallable_Check(pFunc)) { pArgs = e //******************logic to assign struct employee into pArgs pValue = PyObject_CallObject(pFunc, pArgs); } } Py_DECREF(pValue); Py_DECREF(pModule); Py_Finalize(); return 0; } and now python script test.py def testStruct(): # **** need any parameter will be specify #**** assign value into the cStructure f=open(filename) f.write(cStructure.Value) # **** value to write in file Thanks in advance regards ah
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32