In Python, is it possible to mimic JavaScript arrays (i. e., arrays that expand automatically when values are added outside the array's range)? In JavaScript, arrays expand automatically when a value is assigned outside of an array's index, but in Python, they do not:
theArray = [None] * 5
theArray[0] = 0
print(theArray)
theArray[6] = 0 '''This line is invalid. Python arrays don't expand automatically, unlike JavaScript arrays.'''
This would be valid in JavaScript, and I'm trying to mimic it in Python:
var theArray = new Array();
theArray[0] = 0;
console.log(theArray);
theArray[6] = 0; //the array expands automatically in JavaScript, but not in Python
python_list[100] = "whatever", you'd have to doinsertWithAutoFill(python_list, 100, "whatever"). I just wrote a simple function that does that. Would that be a problem to use/implement? It's either that, or creating your own class that mimics a list with this special functionality as a method