Ok, so I count 87 statements that open a file. I believe there are a lot of duplicates, triplicates? Couldn't I just add "UseRelativePaths = True" ? (-:
What's worse is that I believe that about 1/3 of the code is obsolete. It has been worked on by numerous programmers over the last 20 years. Little of it is commented. I wonder if I could convince IT to stay with Win 10. Why did this change with Win 11? -----Original Message----- From: MRAB <[email protected]> Sent: Thursday, February 26, 2026 2:35 PM To: [email protected] Subject: Re: Win 10 > Win 11 path error? On 26/02/2026 17:53, Em wrote: > OutExcelFile = open("_EXCEL-FILE3az.txt","w") > > The line works in Win 10. > In Win 11, if I press F5 it works but if I double click on the program > filename, it fails immediately. > No error reported. > > I believe the problem with the path needing to be different between Win10 and > Win11. > Can you tell me what the path should be if that is the problem? > > Python: 3.14.1 > "_EXCEL-FILE3az.txt" is a relative path. It looks in the current working directory, wherever that happens to be. It's better to work with full filepaths. The path of the script is given by `__file__`, and its directory by `os.path.dirname(__file__)`, so: this_directory = os.path.dirname(__file__) If "_EXCEL-FILE3az.txt" is in the same directory as the script, its full path will be given by: data_path =os.path.join(this_directory, "_EXCEL-FILE3az.txt") You can then write: OutExcelFile = open(data_path,"w") -- https://mail.python.org/mailman3//lists/python-list.python.org -- https://mail.python.org/mailman3//lists/python-list.python.org
