I have a custom python class
object added to a list upon instantiation.
I would like for the python class
object to remove itself from the list and remove itself from any memory running on the ram or I'm basically looking for a destructor for the class
object and a method to remove the instance from the python structure. I'm not tied to using a list and am open to suggestions about what might be a better container, or any other suggestions on coding style.
Bad pseudocode example of what I'm essentially going for:
mylist=[]
class myclass:
def __init__(self,val):
self.v=val
print(self.v)
mylist.append(self)
# The following is what I'm looking for
__superdestructor__(self):
mylist.pop(self)
memory.remove(self)