#include static PyObject * baz(PyObject *self, PyObject *args, PyObject *keywds) { static char *kwlist[] = {NULL}; #if 1 // works with Python 2.4, 2.5 but in Python 2.6 calling baz() gives: // RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:bar.baz') if (!PyArg_ParseTupleAndKeywords(args,keywds,"|:bar.baz", kwlist)) #else // works with all Python versions if (!PyArg_ParseTupleAndKeywords(args,keywds,"", kwlist)) #endif return NULL; return Py_BuildValue(""); } static PyMethodDef BarMethods[] = { {"baz", baz, METH_VARARGS | METH_KEYWORDS, "Baz."}, {NULL, NULL, 0, NULL} /* Sentinel */ }; PyMODINIT_FUNC initbar(void) { Py_InitModule("bar", BarMethods); }