-1

Here is some code (from the docs):

IntArray5 = c_int * 5
ia = IntArray5(5, 1, 7, 33, 99)

How can I do something like:

N = 5
IntArrayN = c_int * N
ian = IntArrayN
ian.append(5)
ian.append(1)
ian.append(7)
ian.append(33)
ian.append(99)

So this raises an Attribute Error

channon
  • 352
  • 2
  • 12

1 Answers1

0

This is the way I was able to do it.

arr=[]
arr.append(5)
arr.append(1)
arr.append(7)
arr.append(33)
arr.append(99)

ian=(c_int*len(arr)(*arr)
print type(arr) # list
print type(ian) #__main.c_int_Array_N

output

<type 'list'>
<class '__main__.c_int_Array_4'>
channon
  • 352
  • 2
  • 12