Trying to make a function to print all the arrays that are dynamically stored inside. But I'm not able to make a function to print all the elements in the array
import ctypes
class myArray(object):
def __init__(self):
self.length = 0
self.capacity = 1
self.Array = self.make_array(self.capacity)
def push(self, item):
if self.length == self.capacity:
self.resize(2*self.capacity)
self.Array[self.length] = item
self.length += 1
print("Hello")
def getitem(self, index):
if index >= self.length:
return IndexError('Out Of Bounds')
return self.Array[index]
def resize(self, new_cap):
newArray = self.make_array(new_cap)
for k in range(self.length):
newArray[k] = self.Array[k]
self.Array = newArray
self.capacity = new_cap
def make_array(self, new_cap):
return (new_cap * ctypes.py_object)()