Python, Programming, Data Science, Artificial Intelligence, Data.
#Code by github.com/tushar2704 class FileHandler: def __init__(self, filename): self.file = open(filename, 'w') def write_data(self, data): self.file.write(data) def __del__(self): self.file.close() print("File closed.") handler = FileHandler("example.txt") handler.write_data("Hello, World!") del