I am trying to creating a python array and have problems with the following code
def __init__(self, size):
assert size>0, "Array size must be > 0"
self._size = size
# Create the array structure using the ctypes module.
arraytype = ctypes.py_object * size
self._elements = arraytype()
In the initialization, it uses ctypes to create an array and I don't really understand the last two lines. I tried to change them into one line
self._elements = ctypes.py_object() * size
But it doesn't work and gives me the error
TypeError: unsupported operand type(s) for *: 'py_object' and 'int'
Could anyone explain it for me?