How do I use python object in C++

lixinyi.23 at lixinyi.23 at
Wed Sep 24 04:30:44 CEST 2008

If the PyObject is a PyList, and all list items are strings,
say a=['aaa','bbb','ccc']

How can I have a
myArray[0] = "aaa"
myArray[1] = "bbb"
myArray[2] = "ccc"
in C++?

Do I have to
use PyModule_GetDict() to get the dict first?
what about the next?

> What do you know about the contents of 'argc' and 'argv'?  If it's
> impossible with Py_Main, can you use one of the other entry points?
> If you've never manipulated PyObject* objects in C, they can be
> hairy.  Even if you know 'a' is a sequence, its contents are still all
> PyObject*s, which you can access via PyList_... and PySequence_
> functions.

More information about the Python-list mailing list