Search Results

Search found 1 results on 1 pages for 'pc05'.

Page 1/1 | 1 

  • How do I convert a Python list of lists of lists into a C array by using ctypes?

    - by pc05
    As seen here How do I convert a Python list into a C array by using ctypes? this code will take a python array and transform it to a C array. import ctypes arr = (ctypes.c_int * len(pyarr))(*pyarr) Which would the way of doing the same with a list of lists or a lists of lists of lists? For example, for the following variable list3d = [[[40.0, 1.2, 6.0, 0.3], [50.0, 4.2, 0, 0]], [[40.0, 1.2, 6.0, 0.3], [50.0, 4.2, 0, 0]], [[40.0, 1.2, 6.0, 0.3], [50.0, 4.2, 0, 0]]] I have tried the following with no luck: ([[ctypes.c_double * 4] *2]*3)(*list3d) # *** TypeError: 'list' object is not callable (ctypes.c_double * 4 *2 *3)(*list3d) # *** TypeError: expected c_double_Array_4_Array_2 instance, got list Thank you! EDIT: Just to clarify, I am trying to get one object that contains the whole multidimensional array, not a list of objects. This object's reference will be an input to a C DLL that expects a 3D array.

    Read the article

1