i'm trying to create a def for log file and this is my script:
import sys
import time
path= 'pc_path'
file = path + '\\' + 'test.txt'
files = open(file, 'w')
files.close()
def log(msg):
    time = time.time()
    filess = open(file, 'a')
    filess.write(msg)
    filess.close()
val = 10
val1 = 32
try:
    operazione = val + val1
    print('ok')
    print(operazione)
    msg = operazione
    log(msg)
except:
    sys.exit()
the script create a txt file but does not write a def() function into txt Thanks
 
     
     
     
    