Does reading a file through a Python script (or any other code) change the file's Last-Time-Access properties?

56 views Asked by At

I have written a Python program that reads multiple files and looks for some information.

Here is the command that I used:

try:
    with open(file_path, "r") as file_object:
        # do some stuff
except:
    # do some stuff

It works correctly as I wanted.

I have noticed that after running the code, the file properties Accessed changed for all the files that the code read, though code just read the file.

Interestingly, I ran the same program in a different machine with Python 3.7 and the file properties didn't change. I couldn't remember the actual version of the previous Python but it surely changed the file Accessed properties to the time I ran the code.

What is the reason behind this? Did an older version of Python change the file Accessed properties when the code read a file but the new version doesn't?

In both cases Windows 10 OS was used, files were text files. For the later case, file system is NTFS.

0

There are 0 answers