class TestClass(object):
    def __init__(self):
        pass
    def __del__(self):
        with open('log', 'w+') as fL:
            fL.write('__del__')
if __name__ == '__main__':
    test = TestClass()
Ran the script and got the error message: NameError: name 'open' is not defined