I run python code where i create multiple objects from 1 class and register these object in an IterRegistery:
class IterRegistry(type):
def __iter__(cls):
return iter(cls._registry)
class exampleclass(metaclass=IterRegistry):
_registry = []
def __init__(self, number):
self._registry.append(self)
self.number = number
def destroy(self):
if self.number == 1:
del self
exampleclass(1)
exampleclass(2)
for e in exampleclass:
e.destroy
Now i would like an object to delist itself from the registery and destroy itself from the inside out if several requirements are met. It tried to do this by using:
del self
But that's not working.
Is there a proper way to achieve this?