Skip to content
Advertisement

Missing attribute `value` for equal ctypes array objects

I know 2 ways of creating a c array out of a python sequence data = (1, 2, 3, 4, 5, 6).

Creating an array class, initializing it and passing the values through the value attribute:

JavaScript

Creating an array class and passing the value as arguments during initialization:

JavaScript

Both generates the same type:

JavaScript

But when trying to access the value attribute:

JavaScript

Why doesn’t array2 has a value attribute? My understanding is that these arrays are the same type but just initialized differently.


And even if I create two different arrays with two different values, the problem still occurs:

JavaScript

Advertisement

Answer

You define array1.value as data. But you didn’t specifically define array2.value. By default .value is not define (even if the array contains the values).

JavaScript

As you can see, you can still have access to the values of array2 using standard python call for list.

You can have a look at Python’s documentation, especially on fundamental data types and on arrays and pointers.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement