класс Test:
def __init__(self, number):
self.number = number
fh = open(r"DesktopNow.txt", 'a')
fh.write(f"New object having number {self.number} has been createdn")
fh.close()
def __del__(self):
fh = open(r"DesktopNow.txt", 'a')
fh.write(f"Object number {self.number} destroyed")
fh.close()
t1 = Тест (1)
t2 = Тест (2)
t3 = Тест (3)