Guest User

Untitled

a guest
Jun 30th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. Writing a Python C extension: how to correctly load a PyListObject?
  2. static PyObject *orbital_spectra(PyObject *self, PyObject *args) {
  3. PyListObject *input = (PyListObject*)PyList_New(0);
  4. real channels[7], coefficients[7], values[240];
  5. int i;
  6.  
  7. if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &input)) {
  8. return NULL;
  9. }
  10. for (i = 0; i < PyList_Size(input); i++) {
  11. printf("%fn", PyList_GetItem(input, (Py_ssize_t)i)); // <--- Prints zeros
  12. }
  13. //....
  14. }
  15.  
  16. printf("%fn", PyFloat_AsDouble(PyList_GetItem(input, (Py_ssize_t)i)));
Advertisement
Add Comment
Please, Sign In to add comment