Is it possible to delete an object by using a weak reference to it?
Basically, I have a weakref object which contains references to all of the objects that are instances of the same class. This is contained in a class attribute which all the objects have, i.e.
weakref_obj = class.instances
I can iterate over the weakref object and return object attributes. I want to delete the object which has a certain _id attribute. I tried:
for item in weakref_obj:
if item._id == "P":
del item
I understand that I could do what I want by using a standard dictionary storing all the objects but this would require more coding, so if I could somehow do it using the weakref object that would be great.
Thanks