PyArg_ParseTuple for parsing list and dictionary arguments
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue Sep 16 04:02:08 EDT 2008
En Mon, 15 Sep 2008 06:58:48 -0300, Pau Freixes <pfreixes at gmail.com>
escribió:
> Hi to all,
>
> What's the best way for parse one list or dict argument with
> PyArg_ParseTuple Function ?
>
> If I have this python code :
>
> import example
>
> example.test("hellow", ["a", "b"], { "a" : 1 })
>
> The c extension for implementation test function must be like this :
>
> static PyObject * test( PyObject *self, PyObject *args)
> {
> PyObject * dict, * list;
> char * string;
>
> PyArg_ParseTuple(args, "sOO", string, dict, list);
> ......
> }
I don't understand the actual question - the example looks fine, what's
your problem?
Do you want to check the object types? Use PyDict_Check / PyList_Check.
--
Gabriel Genellina
More information about the Python-list
mailing list