I have a ModelManager
which keeps track of creating and destroying new objects. Here's an example:
class ModelManager:
MAX_OBJECTS = 10
OBJECTS = {} # hash to model object
NUM_OBJECTS = len(OBJECTS) # how to dynamically calculate this?
Every time an object is created it is added to OBJECTS
and everytime it is deleted it gets popped from OBJECTS
.
How would I properly do the NUM_OBJECTS
here? Ideally it should be a classmethod/property to act as a calculation. For doing something like the above, what would be the best way?
I would like to call it as ModelManager.NUM_OBJECTS