Safe to change base class in python? -
Such questions exist, but not at all, and I did not get a completely satisfactory answer.
I am doing an agent-based biological model. Suppose I have a class of cell type A, and one of the B. They age according to a clock. Let's say that when a cell of type A reaches a certain age, then it turns into cell of B.
I have a list of cells that I just do not want to make new B cells, and want to add them to inventory and still leave A cells in inventory.
It seems to work, but is it safe?
Class B (object): Pass the class A (object): def changeToB (self): self .__ class__ = B Or, what Any better way? Text after "
It can be safe for interpreter, it's definitely going to understand one It is unsafe to trying.
Compared to organic cell, it is difficult to make object design more natural mapping and you are trying to leave it there naturally. A cell is as a function of age Age and various mechanisms are switched on and off in the world, an osteblast does not come out of existence and osteocyte takes its place, but cell identifies it Retains, but behaves differently on the basis of the state's values of age. I definitely think about coding this kind of model in the object model.
Comments
Post a Comment