En Sat, 19 Dec 2009 07:36:59 -0300, Emeka <emekami...@gmail.com> escribió:

Okay if that is the case, why do we need it? By having int a = 65, b = 66 ,
why should we also have *kwlist[]?



static PyObject* foo(PyObject *self, PyObject *args, PyObject *kwrds)
{
   int a=65, b=66;
   char *kwlist[] = {"a", "b", NULL};
   if (!PyArg_ParseTupleAndKeywords(args, kwrds, "|CC", kwlist, &a,
&b))
       return NULL;
   return Py_BuildValue("(CC)", a, b);
}

It's not related to default values. foo(x=30) should raise an error; the
allowed parameter names are only 'a' and 'b', not 'x'.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to