Python C/API - *arg,**kwds variable argumnents

Fredrik Lundh fredrik at pythonware.com
Wed Dec 14 12:57:41 EST 2005


mdcb808 at gmail.com wrote:

> I am writing a C extension with python 2.3.5 and need constructs
> similar to python
>    func(*args, **kwds)
> What's a neat way to do that?

static PyObject*
myfunc(PyObject* self, PyObject* args, PyObject* kw)
{
    ... args is a tuple, kw is a dictionary ...
}

static PyMethodDef _functions[] = {
    {"myfunc", (PyCFunction) myfunc, METH_VARARGS|METH_KEYWORDS},
    {NULL, NULL}
};

</F>






More information about the Python-list mailing list