My requirement is to checks to see if a file has changed since the last run.
I have made an attempt to do with this os.stat
and I'm not sure whether it is a correct way or not.
import os
import json
file_info = os.stat("cli.py")
with open("log.txt", "r") as file:
line = json.loads(file.readline())
if list(set(line)-set(list(file_info))):
print("Changes in file")
with open ("log.txt", "w+") as f:
f.write(str(list(file_info)))
I looking for is there any better ideas or am I doing it in correct way or not. Any help is appreciated