Re: PyArg_ParseTuple for parsing list and dictionary arguments

Discussion in 'Python' started by Gabriel Genellina, Sep 16, 2008.

  1. En Mon, 15 Sep 2008 06:58:48 -0300, Pau Freixes <>
    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
    Gabriel Genellina, Sep 16, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Gross
    Replies:
    0
    Views:
    614
    Michael Gross
    Jul 30, 2003
  2. =?iso-8859-1?b?IkrpcvRtZQ==?= Laheurte

    Re: Python/C API - PyArg_ParseTuple problem ?

    =?iso-8859-1?b?IkrpcvRtZQ==?= Laheurte, Aug 22, 2003, in forum: Python
    Replies:
    1
    Views:
    386
    =?iso-8859-1?b?IkrpcvRtZQ==?= Laheurte
    Aug 22, 2003
  3. Skip Montanaro
    Replies:
    1
    Views:
    332
    Torsten Mohr
    Jun 7, 2004
  4. Replies:
    4
    Views:
    568
    Jeff Epler
    Jun 6, 2005
  5. Replies:
    2
    Views:
    128
    Stefan Behnel
    Jan 23, 2013
Loading...

Share This Page