What's the idiomatic way of assigning array elements in a ctypes.Structure? For example, given:
from ctypes import Structure, c_float
class Foo(Structure):
_fields_ = (
('arr', c_float*3),
)
values = [1.1, 2.2, 3.3]
I expected to be able to just do:
foo = Foo()
foo.arr = values
but this complains about type mismatch.
TypeError: expected c_float_Array_3 instance, got list
I'm adding an answer showing what I've gone with, but would be interested to know of any more definitive answers.