I am writing a C extension and I completely lost how to get the dict as an argument. Since the documents do not have any specifics on how to do this, I tried to parse the argument as a Python object and then manipulate it as a dict:
PyTypeObject *dict; if(!PyArg_ParseTuple(args, "o", &dict)) return NULL;
But the code does not execute on parsing:
Python 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import plotting >>> plotting.plot({'wff':0}) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: must be impossible<bad format char>, not dict
As far as I understand from the error message, the char format is incorrect (I thought that "o" should represent any Python object).
What is the best way to parse a Python dict into a C pointer? I am digging documentation, but I have not found anything like it.
Thanks.
source share