i'd like to do some cleanup whenever an instance is deleted at runtime, but not during garbage collection that happens on exit.
in the example below, when c is deleted, a file is removed, and this is what i want; however, that file is also removed when the program exits, and this is NOT what i want.
class C:
def __del__(self):
os.remove(self.filename)
c=C()
del c
can i tie runtime instance deletion with a block of statements, but not execute that same block when python exits?
thanks.