unpacking Python tuple in C
Mike Müller
mmueller at dgfz.de
Wed Dec 13 08:30:12 EST 2000
>>
>> PyObject* floatFromPy0 = PyTuple_GetItem(result, 0);
>> *double1= PyFloat_AsDouble(floatFromPy0)
>>
>> since the tuple is pretty long and I need all of the tuple items
>> PyTuple_GetItem seems to not the best solution.
>
>Why not? Why not use a loop and stuff the values into an array of
>doubles?
Thanks for the tip. This works. As you can tell I don't have much experience
with C,
so simple things can cause big trouble.
>
>Supplying the right number of d's to PyArg_ParseTuple, maybe?
Tried "ddd...d" with an without ( ). No success.
But the loop with the array works (see above) and this just what I want.
>Stepping back from your immediate problem, what are you actually
>trying to do? I can infer it from what you've said here, I'm afraid.
I am writing my program in Python (it's a water quality model). There is a
"main" model written by somebody else in FORTRAN which calls submodels as
DLLs. My Python model is one of these submodels. Now I try to speeze
everything into a DLL. So C is the "glue" and just has to pass some args
back and force from the main to the submodel. I do NOT program any
functionallity in C (just the argument passing via the DLL). Besides this it
seems I need to improve my knowledge of C.
Thanks for your help.
Mike
More information about the Python-list
mailing list