Obversation 1: On Windows 10, I open two command windows ("cmd"). On both, I start python for an interactive session. In both, I open my test file via f = open("test.xlsx", "a+")
. No error message in the second command window, despite the file being already opened for writing in the first window!
Observation 2, another test: If I open the file with Excel itself first, then try to open the file simultaneously for writing ("a+") in one of my python sessions, I get PermissionError. As I would expect.
Observation 3: It's basically the same if I flip the order around: if I open the file in one of my Python sessions first for writing and then with Excel itself, I get the "read-only" notification by Excel since the file is in use by "another user". As expected.
Why does observation 1 occur? Observation 3 shows that python does leave some kind of lock or notification for other programs. So regarding observation 1, why does python itself ignore its own "lock or notification" (however that works, helpful links for a deeper understanding much appreciated!) which the first interactive python session apparently is using in the background (otherwise observation 3 would not have occured)?