You can probably put together some kind of wrapper using a dictionary:
class CppArray:
def __init__(self, value):
if value == None:
self.data = {}
self.length = 0
else:
self.data = { 0: value }
self.length = 1
def insert(self, index, value):
while index in self.data:
tmp = self.data[index]
self.data[index] = value
value = tmp
index = index + 1
self.data[index] = value
if index >= self.length:
self.length = index + 1
def __getitem__(self, index):
if (index < 0 or index >= self.length):
# must create IndexException
raise IndexException("Index out of range")
if index in self.data:
return self.data[index]
else:
return None
x = CppArray("i")
x.insert(0,10)
x.insert(200,30)
x[1]
Obviously this quick sketch is missing many details which would make the class more useful.
For other ideas on special methods you could use, check:
https://docs.python.org/3/reference/datamodel.html