I need to make a matrix of objects in python. I have found other solutions in various languages however cannot find a reliable and efficient method to do this in python.
Given the class
class Cell(): def __init__(self): self.value = none self.attribute1 = False self.attribute2 = False
I want to make a matrix of multiple 'cells' as efficiently as possible. Any contributions are useful.
If you know in advance what size your matrix is you could initialize a numpy array using
np.zeros and then fill in the cells using indexing.
Or you could append items to lists and then convert to an array by
You'll want your matrix as a numpy array for any calculations you do.