On 12/7/2025 3:37 PM, Em wrote:



-----Original Message-----
From: Roel Schroeven <[email protected]>
Sent: Sunday, December 7, 2025 12:26 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION

Op 7/12/2025 om 15:46 schreef Thomas Passin:
On 12/7/2025 7:22 AM, Roel Schroeven wrote:
Op 7/12/2025 om 1:54 schreef Thomas Passin:
As I explained in my last post, that's because in Windows 11 when
double-clicking, the working directory is the system's Windows
directory, not the one your program is in.
Irrespective of anything else that's going on, that's not my
experience. I just tried, and double-clicking a python script makes
the directory that I have open in Explorer the current directory.
I've seen the same not just with scripts but also with executables. I
don't think this is the cause.

It *was* the case *on my system* when I tested the program under
consideration.  I included the output and it clearly showed that the
working directory at launch was C:\WINDOWS\system32.

The situation about file associations in Windows 11 is complicated
because there is the new mechanism, and the old one is still there,
apparently, and they may not always work the same way.
Indeed, clearly there are differences between different installations.

By the "old" mechanism I mean the way that the associations were set
up in the registry by specifying a logical name like Python.file for
the .py extension, and having registry keys for the default program to
use for Python.file types. You could display (or change, I think,
though I never did) these associations from the command line with the
programs assoc and ftype. For example, I used to be able to run this:

C:\Users\tom>ftype Python.file
Python.file="C:\Windows\py.exe" "%L" %*

Now I get this:

C:\Users\Tom>assoc .py
File association not found for extension .py

C:\Users\Tom>ftype Python.file
File type 'Python.file' not found or no open command associated with it.
My Windows 11 still shows

C:\Users\Roel Schroeven>ftype Python.file Python.file="C:\Windows\py.exe" "%L" 
%*

So yeah, there are differences, and I have to admit I'm not familiar with how 
those things work.
At any rate, the OP has been making things harder by not following, or
not following completely, the simple suggestions that have been made.
He needs to find out what the working directory is when the program is
run by double-clicking, or he has to make his program work no matter
what the startup directory is.  Sample code for all that has been
posted in this thread.
I completely agree. Yes, it can be frustrating when something that has always 
worked doesn't work anymore.

But it seems OP prefers to only complain about it instead of trying to find the 
exact cause and/or a solution,
despite lots of suggestions in this thread.

[SGA]  Sorry if my knowledge of all this is not as vast as yours.  Maybe it is 
only half-vast.
You totally missed the point if you believe that I prefer "to only complain about it 
instead of trying to find the exact cause..."  The majority of what is suggested is 
foreign to me in commands and in system responses.  It is rather arrogant to believe that 
your answer is the one that will totally answer the problem. Have you ever indicated that 
you have the same problem and that your suggestion helps?

Now you are missing the point. You wrote "The majority of what is suggested is foreign to me in commands and in system responses." That's fine, you just haven't needed to learn these things yet. What would help the rest of us help you is to say what you don't know how to do, or you don't quite understand.

For example, I posted a version of your program that enclosed the file write operation in a try....except block so that the error could be displayed if the operation failed. That's the program I ran that showed that (on my system) the default directory was the system Windows directory instead of the program's directory. Now you should copy that program and paste it into a .py file in your own program's directory. Then double-click on its name, and you (and we, if you tell us) will know what the result is.

Once you know that, others have posted good solutions, like the one to have your program change the working directory. So copy those lines of code into your program. If you don't understand which lines, where to put them, or what they do, just post back and say so. But remember - be specific. Don't just say "I don't understand". Say e.g., "I don't understand what 'from os.path import dirname, join' is there for". Or "I don't know which lines of code you mean." Don't say "My program failed". Explain what you noticed that had you say that it failed.

So far, only one response here indicated that this problem happened on a system 
other than just mine.  Maybe it occurs on all systems.

P.S.: I am trying to set Outlook to use the ">" indicators but that option is 
faded and not available to enable.
[SGA]


--
"The major problem—one of the major problems, for there are several—one of the 
many major problems with governing people is that of whom you get to do it; or 
rather of who manages to get people to let them do it to them.
To summarize: it is a well-known fact that those people who must want to rule 
people are, ipso facto, those least suited to do it.
To summarize the summary: anyone who is capable of getting themselves made President 
should on no account be allowed to do the job."
          -- Douglas Adams, The Restaurant at the End of the Universe



--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to