Arrays and CTYPE

Nobody nobody at nowhere.com
Tue Sep 21 14:29:04 CEST 2010


On Mon, 20 Sep 2010 15:47:32 -0700, Glenn Pringle wrote:

> Ok. I ran into a problem here. I have been dabbling with Python and I
> thought that this would be a good exercise but I got stuck.
> 
> I have a DLL and one of the functions(getState) in that DLL returns an
> array.

If the DLL was written in C (or C++), it can't return an array; it will
return a pointer instead.

> I'm having a hard time getting access to the contents of that
> array.

Set getState.restype to a pointer type, e.g.:

	hold.getState.restype = POINTER(c_int)

Pointer types can be indexed with [], as in C.




More information about the Python-list mailing list