log.close() if os.path.isfile("log.log"): os.remove("log.log") shutil.move("temp_log.log", "log.log") # end of file