dynamic parameters

Kragen Sitaker kragen at canonical.org
Sat Nov 24 02:11:02 EST 2001


(By the way, Lua is cool!)

luiz at fabricadigital.com.br (Luiz Carlos Silveira) writes:
>         I already can call Lua functions from Python, but I have a
> problem when calling Python functions from Lua. My problem is that
> when I call a Python function, I don't know which function it is, so I
> don't now how many parameters it will take.
>         My question is: how can I pass (dynamically) all the
> parameters that the function should receive?
>         I'm using the Py_BuildValue function. As far as I could see,
> this function only allows me to pass a determined number of
> parameters.

Well, you can't use Py_BuildValue.  I think you can use PyTuple_New to
create a tuple, then use PyTuple_SET_ITEM or PyTuple_SetItem to fill
it in, then use PyObject_CallObject (as you're presumably doing).
There's some sample code for some of this in the 'Reference Count
Details' section of the Python/C API Reference Manual.





More information about the Python-list mailing list