Is there a PyArg_ParseKeyw ords along the lines of
PyArg_ParseTupl eAndKeywords? I want to parse only the keywords,
ignoring the arguments. Currently I do this with something like:
const char *format = "O:min";
static char *kwlist[] = {"key", 0};
PyObject *empty_args = Py_BuildValue(" ()");
if (!PyArg_ParseTu pleAndKeywords( empty_args, kwds, (char *)format,
kwlist, &keyfunc)) {
return NULL;
}
Py_DECREF(empty _args);
but I'm hoping there's a way around creating an empty argument tuple. I
assume I could just use PyDict_GetItemS tring on the kwds directly, but
I'd rather not have to duplicate all the error checking in vgetargskeyword s.
(If you're wondering why I would want such a thing, the application is
adding a 'key' keyword argument to min/max, and it can't be considered
as a positional parameter or the max(a, b, c, key=func) form will treat
func as another item to be compared.)
Steve
PyArg_ParseTupl eAndKeywords? I want to parse only the keywords,
ignoring the arguments. Currently I do this with something like:
const char *format = "O:min";
static char *kwlist[] = {"key", 0};
PyObject *empty_args = Py_BuildValue(" ()");
if (!PyArg_ParseTu pleAndKeywords( empty_args, kwds, (char *)format,
kwlist, &keyfunc)) {
return NULL;
}
Py_DECREF(empty _args);
but I'm hoping there's a way around creating an empty argument tuple. I
assume I could just use PyDict_GetItemS tring on the kwds directly, but
I'd rather not have to duplicate all the error checking in vgetargskeyword s.
(If you're wondering why I would want such a thing, the application is
adding a 'key' keyword argument to min/max, and it can't be considered
as a positional parameter or the max(a, b, c, key=func) form will treat
func as another item to be compared.)
Steve