Restituendo una tupla di più oggetti in Python API C
-
29-09-2019 - |
Domanda
Sto scrivendo una funzione nativa che restituirà più oggetti Python
PyObject *V = PyList_New(0);
PyObject *E = PyList_New(0);
PyObject *F = PyList_New(0);
return Py_BuildValue("ooo", V, E, F);
Questa compila bene, tuttavia, quando io lo chiamo da un programma Python, ottengo un errore:
SystemError: Bad formato char passato a Py_BuildValue
Come può questo essere fatto correttamente?
EDIT: I seguenti lavori
PyObject *rslt = PyTuple_New(3);
PyTuple_SetItem(rslt, 0, V);
PyTuple_SetItem(rslt, 1, E);
PyTuple_SetItem(rslt, 2, F);
return rslt;
Tuttavia, non c'è un modo più breve per fare questo?
Soluzione
Credo che vuole maiuscole O? "OOO"
, non "ooo"
.
Altri suggerimenti
Cython .
return V, E, F
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow