Is there a PyArg_ParseKeywords along the lines of PyArg_ParseTupleAndKeywords? 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_ParseTupleAndKeywords(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_GetItemString on the kwds directly, but I'd rather not have to duplicate all the error checking in vgetargskeywords.

(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
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to