On May 12, 2:49 pm, "Carsten Haese" <[EMAIL PROTECTED]> wrote: > On 11 May 2007 21:11:06 -0700, fabian.conrad wrote > > > Hi, > > sorry for the rather basic question but I've searched everywhere and > > don't find an answer. > > I want to call PyObject_CallObject from the Python C-API and pass a > > tuple I've created from a C-array > > > How can I pass the tuple as an object rather then having to declare > > the python function with the number of arguments equal to the no of > > elements in the tuple? > > The documentation athttp://docs.python.org/api/object.htmllists various Call > flavors. The one you chose will unpack the tuple as if you called > pFunc(*pArgs), which results in the undesired behavior of pFunc receiving > three arguments. You want it to receive one argument that is the tuple pArgs. > > One (bad) way of achieving this would be to build another tuple of size one, > stick pArgs into it, and pass that size-one tuple to PyObject_CallObject. A > better way is to use PyObject_CallFunctionObjArgs. If I'm not mistaken, you'll > want something like > > pValue = PyObject_CallFunctionObjArgs(pFunc, pArgs, NULL); > > Hope this helps, > > -- > Carsten Haesehttp://informixdb.sourceforge.net
Thanks billions!!! Works perfect, the world would be a lot worse without Pro's like you guys helping newbies like me ;-) -- http://mail.python.org/mailman/listinfo/python-list