PyList_GetItem() returning a reference
Question:
I am using the PyHelper class that I found HERE
My python script is returning a list and in C++ I can call PyList_Size() and successfully get the size but when I try get item it returns a very large number which I assume is a address reference rather than the actual list element
args is defined as CPyObject args = PyTuple_New(1);
I am expecting to see the actual elements which are in the list that I can then assign to a string in order to use them in C++ without having to use PyObject further
Answers:
This has been solved thanks to help from CristiFati
the issue was that the PyScript was returning a list of dictionaries which meant in C++ the use of both PyList functions and PyDict functions was needed in order to parse the data.
For example
PyList_Size(pValue) in order to get the size of the list
but then in order to access the dictionaries in the list the following code was needed
CPyObject pListItem = PyList_GetItem(pValue, i);
PyDict_GetItemString(pListItem, "content")
I am using the PyHelper class that I found HERE
My python script is returning a list and in C++ I can call PyList_Size() and successfully get the size but when I try get item it returns a very large number which I assume is a address reference rather than the actual list element
args is defined as CPyObject args = PyTuple_New(1);
I am expecting to see the actual elements which are in the list that I can then assign to a string in order to use them in C++ without having to use PyObject further
This has been solved thanks to help from CristiFati
the issue was that the PyScript was returning a list of dictionaries which meant in C++ the use of both PyList functions and PyDict functions was needed in order to parse the data.
For example
PyList_Size(pValue) in order to get the size of the list
but then in order to access the dictionaries in the list the following code was needed
CPyObject pListItem = PyList_GetItem(pValue, i);
PyDict_GetItemString(pListItem, "content")