Problems returning data from embedded Python
cromulent at justextrememetal.com
Wed Aug 13 00:48:54 CEST 2008
On 2008-08-12 05:37:53 +0100, "Gabriel Genellina"
<gagsl-py2 at yahoo.com.ar> said:
> En Mon, 11 Aug 2008 12:58:00 -0300, Cromulent
> <cromulent at justextrememetal.com> escribi�:
> Uh? You have a complete API for working with list objects, the
> functions named PyList_*
> See http://docs.python.org/api/listObjects.html
> There is also an abstract layer that works both with lists and tuples:
> If that's not what you are after, please provide more details...
Spoke too soon.
Right, I've rewritten the Python program and it returns a tuple of
lists and one integer. Basically as you saw before, the python program
reads a file in, splits it into elements that were separated by a comma.
The new program just puts each element into its own list. Here is a
line from the file I am reading in:
so basically I have 6 lists and one int (which is the total number of
lines read by the program) I then return that tuple to the C program.
After that I call the following:
error = PyArg_ParseTuple(value, "isffffi", &totalLines, &finopen,
&finclose, &finhigh, &finlow, &finvolume);
but that will only give me the first element of the list. What I would
like to do is return the total number of lines read separately, then
use that to allocate a C99 style variable sized array and then loop
through the call to PyArg_ParseTuple to populate the array. The problem
with that is that I don't think PyArg_ParseTuple is designed in that
way. It will put the contents of the list in the variable and not split
it up so that I can populate an array.
Am I making any sense? Probably not, but it is hard to explain.
Thanks for any help.
"I disapprove of what you say, but I'll defend to the death your right
to say it." - Voltaire
More information about the Python-list