python ctypes array will not return properly
<p>This does not work:</p>

<pre><code>def CopyExportVars(self, n_export):
    export_array = (ctypes.c_double * n_export)()
    self.dll_handle.vs_copy_export_vars(ctypes.cast(export_array,  ctypes.POINTER(ctypes.c_double)))
    return export_array().contents
</code></pre>

<p>I get this error (<code>n_export</code> is 3):</p>

<pre><code>TypeError: 'c_double_Array_3' object is not callable
</code></pre>

<p>Error is pretty self-explainatory. <code>export_array</code> is not a callable object, but you try to call it in last line of function. Also, you try to use pointer-related interface ('.contents') to retrieve value from array, not pointer to it.</p>

<p>Simplest way to make it work would be to convert <code>ctypes</code> result array to pure Python object and return it: </p>

<pre><code>def CopyExportVars(self, n_export):
    export_array = (ctypes.c_double * n_export)()
    self.dll_handle.vs_copy_export_vars(ctypes.cast(export_array,  ctypes.POINTER(ctypes.c_double)))
    return list(export_array)
</code></pre>

python arrays ctypes