isinstance(the_parameter, ctypes.Array)
will check for a ctypes array.
ctypes defines the following simple scalar types (note, they're private):
_SimpleCData # _type_: 'P' for void *
_Pointer # _type_: ctypes.c_int
_CFuncPtr # _flags_, _restype_, _argtypes_, _check_retval_
While you can subclass these types directly, for the most part you should use the existing subclasses and factory functions such as c_void_p
, POINTER
and CFUNCTYPE
.
ctypes defines the following aggregate types:
Array # _type_, _length_
Structure # _fields_, _anonymous_, _pack_, _swappedbytes_
Union # _fields_, _anonymous_, _pack_, _swappedbytes_
Array
subclasses are typically created by sequence repetition using the *
operator, e.g. IntArray = c_int * 10
. You could instead use the following:
class IntArray(ctypes.Array):
_type_ = ctypes.c_int
_length_ = 10
a = IntArray(*range(10))
a_list = a[:]