[EMAIL PROTECTED] wrote: > hello all, > how to parse the arguments of a c function with PyArg_ParseTuple? > The prototype of the c function is : > int func(unsigned char * in , int inlen, unsigned char * v, unsigned > char * out, int * outlen); > > The problem is , when the func returns, there will be results in out > and outlen. Is the following format is correct?
As the ``out'' and ``outlen'' are used for output, you should not pass them to a python function as parameters. Instead, you'd better make the return value of the python function to represent them (if the python caller wants them, of course). In your case, returning a python string object will be a good choice if outlen is the length of out array, since a python string knows its length. So, you need only parse the parameters of ``in'', ``inlen'' and ``v'' in the wrap function. And even further, the python caller can pass a python string to replace ``in'' and ``inlen''. Then, the prototype of the function is something like: def func(ins, v) which returns a string. [...] -- Qiangning Hong -- http://mail.python.org/mailman/listinfo/python-list