I have a C library for a device that includes features such as:
int GetDevInfo(int *devices);
In this case, the devices are an array of integers that could be defined as follows:
int devices[10]
The function will go through the hardware bus to search for active devices. When he finds them, he will put the device number in the next available place in devices[]. So, for example, before scanning:
devices = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}and the global variable DeviceCountknows that there are 0 active. The function does its magic and decides that devices 5 and 8 are active. So:
devices = {5, 8, 0, 0, 0, 0, 0, 0, 0, 0}and DeviceCountknows that there are 2.
I want the Python function to be something like:
devices = list(range(64))
for i in range(0,len(devices)):
devices[i] = 0
DeviceCount = 0
DeviceCount = myModule.GetDevInfo(DeviceCount, devices)
When he returns, it DeviceCountcan be set to 2, and the devices look like this:
[5, 8, 0, 0, 0, 0, 0, 0, 0, 0]
, , - -, . , - :
def f(a, data):
a.append(data)
l = [1, 2, 3]
f(l, 4)
l=[1, 2, 3, 4], , Python C.
Thannks , , !