Consider the class below:
class cell:
X_size = 10
Y_size = 10
world = np.zeros((X_size,Y_size))
I want to change the class above into the code below and be able to pass X_size, Y_size to an instance:
class cell:
world = np.zeros((X_size,Y_size))#X_size and Y_size must be passed on the run time
I could do:
class cell:
def __init__(self, X_size,Y_size):
self.X_size = X_size
self.Y_size = Y_size
world = np.zeros((X_size,Y_size))
The problem is that then every instance makes a new world. I want the world to be created once, to be seen by all the instances and then each new instance modify only one of the world's elements which also could be seen by all the other instances. That is why I use the class variable, but then if I use the class variable, it seems I have to determine X_size and Y_size before hand.
cell.world = ...later on. Also, you should name your classes capitalized.X_sizeandY_size, and at the same time, the class variable is supposed to be initialized depending on that value? Unless you mean to change the world size everytime acellis instantiated?