Re: A switch somewhere, or bug? CORRECTION
On 12/5/2025 3:03 PM, Em wrote:
Alright, Alright, Alright...
Alright.
These responses push much more sophisticated explanations than the question
asked. This involves only one line of code that creates an empty text file.
No other code is involved or needed.
Before responding, please run this test:
Create a .py file that contains the line:
Starter = open("HLYlog.txt", "w")
Copy that file onto a folder in a WIN10 computer
which uses Python 3.13 and copy it again onto a folder
in a WIN11 computer that runs Python 3.14.1
Double-click the filename in the folder on the
WIN10 computer. It executes the program and the
text file is created.
Double-click the filename in the folder on the
WIN11 computer and it fails, no text file is created.
No error statement is generated.
The strange thing here is that, on the WIN11 computer,
I right-click and choose "Edit with IDLE" option. The file
code is shown and I press F5. The program runs properly
and the text file is created. Of course, IDLE does not
show an error report on a working program.
The medical program that I wrote, and have used for 20 years,
works on the WIN10 computer. I now want to copy it
to the WIN11 computer and it consistently fails on
this line.
The change from WIN10 Python 3.13 to WIN11 Python 3.14
is the only difference I can see.
You have been mixing up two things, and it's confusing to people who
want to help:
1. Running a .py file by double-clicking the .py file name in Windows
Explorer;
2. Whether or not your program works using this Python install, when run
from the command line in a Console.
Kindly try to run the program with Python from the command line. By that
I mean some variation of "py your_program.py". Of course, you first need
to CD to its directory; otherwise you have to include the full path. See
if it creates the file it's supposed to. If it does, delete the created
file, and try to run the program from the console just using the file's
name, *without* prefixing it with "py", "python" or whatever you used to
run it when it succeeded. You should see a new console flash up for a
moment then close and vanish. See if the file was created.
Running by typing the .py file name by itself should will launch it the
same way it would be launched when you double click on the file name.
If the file was created when you ran your file with the python
executable, that verifies the program ran and functions. Since it works
in IDLE, that should succeed. Then if it fails when typing just the
bare program name, that would show that the file association for .py
files isn't set up. Unfortunately, the new console doesn't stay visible
long enough to see any error messages and you have to work around that
fact to make sure of what is going on.
Another way to check is to right-click on your .py file in Windows
Explorer, and go down to the "Open With" menu item. The first name in
that list should be some variation of "Python (Default)". If that's not
the case, you need to set up the file association using the
Settings/Default apps settings page, as I mentioned in an earlier post.
I suspect that the file association hasn't been set up. That was the
case on my Windows 11 computer too.
-Original Message-
From: Michael Torrie via Python-list
Sent: Friday, December 5, 2025 1:18 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION
On 12/4/25 10:47 PM, Em wrote:
Starter = open("HLYlog.txt", "w")
Thoughts appreciated.
-That's a relative path. Are you sure that the current working
directory is what -you expect? It's generally better to work with
absolute paths.
Relative or not, I can't see how that could possibly make any difference.
You don't? Why? The key word is "working directory." How do you know what
the working directory is? If you start a program using a shortcut link, the
link can specify any arbitrary directory. If you start it from idle, idle
sets the working directory. If you double click the py file, the pylauncher
sets the working directory. All could be and in fact are different. If you
always want it to open that file in the same directory as the script, then
you can use code such as the following:
import os
# Get the absolute path of the current python file we're running
current_file_path = os.path.abspath(__file__)
# Get the directory of the current file
current_directory = os.path.dirname(current_file_path)
print(f"The directory of the current file is: {current_directory}")
(disclaimer, suggested by AI, verified by me to be correct).
--
https://mail.python.org/mailman3//lists/python-list.python.org
--
https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
On 05/12/2025 05:47, Em wrote: -Original Message- From: MRAB Sent: Thursday, December 4, 2025 10:52 PM To: [email protected] Subject: Re: A switch somewhere, or bug? CORRECTION On 04/12/2025 18:25, Em wrote: Two computers, both alike in dignity, in fair windows land, where we set our scene.. in Win10/Python 3.13 my program runs as well as can be expected. However, on my new computer Win11/Python 3.14.1 there is a peculiarity. On the new machine, when I click on the file name, it immediately dumps out. I go in with IDLE and it runs fine with no indication of any error. I believe this line is the culprit: Starter = open("HLYlog.txt", "w") Thoughts appreciated. -That's a relative path. Are you sure that the current working directory is what -you expect? It's generally better to work with absolute paths. Relative or not, I can't see how that could possibly make any difference. It worked on the Win10 computer for both double-tap on the file and when using IDLE. It worked on the Win11 computer when activated through IDLE but not when I double-tapped to activate it. On the WIN11 computer. In other words, it worked on 3/4 of the methods and not on the one of the four. If it's a relative path, it might not be looking in the same directory. If it can't find the find, it'll raise an exception and quit the program if you're not catching the exception. Did it work for you , for both techniques, on a Win11 computer? I recently switched from Windows 10 to Linux, and I've never used Windows 11. -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
On 12/4/25 10:47 PM, Em wrote:
>> Starter = open("HLYlog.txt", "w")
>>
>> Thoughts appreciated.
>
> -That's a relative path. Are you sure that the current working directory is
> what
> -you expect? It's generally better to work with absolute paths.
>
> Relative or not, I can't see how that could possibly make any difference.
You don't? Why? The key word is "working directory." How do you know
what the working directory is? If you start a program using a shortcut
link, the link can specify any arbitrary directory. If you start it
from idle, idle sets the working directory. If you double click the py
file, the pylauncher sets the working directory. All could be and in
fact are different. If you always want it to open that file in the same
directory as the script, then you can use code such as the following:
import os
# Get the absolute path of the current python file we're running
current_file_path = os.path.abspath(__file__)
# Get the directory of the current file
current_directory = os.path.dirname(current_file_path)
print(f"The directory of the current file is: {current_directory}")
(disclaimer, suggested by AI, verified by me to be correct).
--
https://mail.python.org/mailman3//lists/python-list.python.org
RE: A switch somewhere, or bug? CORRECTION
Ok, using "Open with Python" , the program fails on both computers. Still, double-click the filename on the WIN10 computer and the program works. While, double-click the filename on the WIN11 computer and the program fails. -Original Message- From: Thomas Passin Sent: Friday, December 5, 2025 4:34 PM To: [email protected] Subject: Re: A switch somewhere, or bug? CORRECTION On 12/5/2025 3:03 PM, Em wrote: > Alright, Alright, Alright... > Alright. > > These responses push much more sophisticated explanations than the > question asked. This involves only one line of code that creates an empty text file. > No other code is involved or needed. > > Before responding, please run this test: > > Create a .py file that contains the line: > Starter = open("HLYlog.txt", "w") > > Copy that file onto a folder in a WIN10 computer which uses Python > 3.13 and copy it again onto a folder in a WIN11 computer that runs > Python 3.14.1 > > Double-click the filename in the folder on the > WIN10 computer. It executes the program and the text file is created. > > Double-click the filename in the folder on the > WIN11 computer and it fails, no text file is created. > No error statement is generated. > > The strange thing here is that, on the WIN11 computer, I right-click > and choose "Edit with IDLE" option. The file code is shown and I > press F5. The program runs properly and the text file is created. Of > course, IDLE does not show an error report on a working program. > > The medical program that I wrote, and have used for 20 years, works on > the WIN10 computer. I now want to copy it to the WIN11 computer and it > consistently fails on this line. > > The change from WIN10 Python 3.13 to WIN11 Python 3.14 is the only > difference I can see. You have been mixing up two things, and it's confusing to people who want to help: 1. Running a .py file by double-clicking the .py file name in Windows Explorer; 2. Whether or not your program works using this Python install, when run from the command line in a Console. Kindly try to run the program with Python from the command line. By that I mean some variation of "py your_program.py". Of course, you first need to CD to its directory; otherwise you have to include the full path. See if it creates the file it's supposed to. If it does, delete the created file, and try to run the program from the console just using the file's name, *without* prefixing it with "py", "python" or whatever you used to run it when it succeeded. You should see a new console flash up for a moment then close and vanish. See if the file was created. Running by typing the .py file name by itself should will launch it the same way it would be launched when you double click on the file name. If the file was created when you ran your file with the python executable, that verifies the program ran and functions. Since it works in IDLE, that should succeed. Then if it fails when typing just the bare program name, that would show that the file association for .py files isn't set up. Unfortunately, the new console doesn't stay visible long enough to see any error messages and you have to work around that fact to make sure of what is going on. Another way to check is to right-click on your .py file in Windows Explorer, and go down to the "Open With" menu item. The first name in that list should be some variation of "Python (Default)". If that's not the case, you need to set up the file association using the Settings/Default apps settings page, as I mentioned in an earlier post. I suspect that the file association hasn't been set up. That was the case on my Windows 11 computer too. > > > > > -Original Message- > From: Michael Torrie via Python-list > Sent: Friday, December 5, 2025 1:18 PM > To: [email protected] > Subject: Re: A switch somewhere, or bug? CORRECTION > > On 12/4/25 10:47 PM, Em wrote: >>> Starter = open("HLYlog.txt", "w") >>> >>> Thoughts appreciated. >> >> -That's a relative path. Are you sure that the current working >> directory is what -you expect? It's generally better to work with >> absolute paths. >> >> Relative or not, I can't see how that could possibly make any difference. > > You don't? Why? The key word is "working directory." How do you know > what the working directory is? If you start a program using a shortcut > link, the link can specify any arbitrary directory. If you start it > from idle, idle sets the working directory. If you double click the py > file, the pylauncher sets the working directory. All could be and in > fact are different. If you always want it to open that file in the > same directory as the script, then you can use code such as the following: > > import os > > # Get the absolute path of the current python file we're running > current_file_path = os.path.abspath(__file__) > > # Get the directory of the current file current_directory = > os.path.dirname(current_file_path) > > print(f"The
Re: A switch somewhere, or bug? CORRECTION
On Sat, 6 Dec 2025 at 15:52, Michael Torrie via Python-list
wrote:
>
> On 12/5/25 6:36 PM, Chris Angelico via Python-list wrote:
> > On Sat, 6 Dec 2025 at 12:33, Michael Torrie via Python-list
> > wrote:
> >> Starter = open("HLYlog.txt","w");
> >> filepath = Starter.name
> >
> > Isn't that just...
> >
> > filepath = "HLYlog.txt"
>
> yup. But did you miss the os.path.abspath() bit?
>
I didn't, and that part IS useful and relevant, but the opening of the
file just adds potential failure points without really adding
anything.
ChrisA
--
https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
On Sat, 6 Dec 2025 at 18:22, Michael Torrie wrote:
>
> On Sat, Dec 6, 2025, 00:04 Chris Angelico wrote:
>>
>> On Sat, 6 Dec 2025 at 15:52, Michael Torrie via Python-list
>> wrote:
>> >
>> > On 12/5/25 6:36 PM, Chris Angelico via Python-list wrote:
>> > > On Sat, 6 Dec 2025 at 12:33, Michael Torrie via Python-list
>> > > wrote:
>> > >> Starter = open("HLYlog.txt","w");
>> > >> filepath = Starter.name
>> > >
>> > > Isn't that just...
>> > >
>> > > filepath = "HLYlog.txt"
>> >
>> > yup. But did you miss the os.path.abspath() bit?
>> >
>>
>> I didn't, and that part IS useful and relevant, but the opening of the
>> file just adds potential failure points without really adding
>> anything.
>
>
> On the contrary it gives him a file to look for to prove what was happening.
Fair enough. IMO the previously-given advice to run the script from a
shell is going to be more useful, but that works too I guess.
ChrisA
--
https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
On Sat, Dec 6, 2025, 00:04 Chris Angelico wrote:
> On Sat, 6 Dec 2025 at 15:52, Michael Torrie via Python-list
> wrote:
> >
> > On 12/5/25 6:36 PM, Chris Angelico via Python-list wrote:
> > > On Sat, 6 Dec 2025 at 12:33, Michael Torrie via Python-list
> > > wrote:
> > >> Starter = open("HLYlog.txt","w");
> > >> filepath = Starter.name
> > >
> > > Isn't that just...
> > >
> > > filepath = "HLYlog.txt"
> >
> > yup. But did you miss the os.path.abspath() bit?
> >
>
> I didn't, and that part IS useful and relevant, but the opening of the
> file just adds potential failure points without really adding
> anything.
>
On the contrary it gives him a file to look for to prove what was
happening.
>
--
https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
On 12/5/2025 10:33 PM, MRAB wrote:
On 06/12/2025 00:52, Thomas Passin wrote:
On 12/5/2025 7:12 PM, Em wrote:
Ok, using "Open with Python" , the program fails on both computers.
Still, double-click the filename on the WIN10 computer and the program
works.
While, double-click the filename on the WIN11 computer and the program
fails.
Then set up the file association for .py files in Settings/Default
apps. And write a different test program, one that will stay around so
you can see error messages. Perhaps (untested)
from time import sleep
print('this is a test')
sleep(10) # sleep 10 seconds
# or
# while True:
# sleep(10) # Break out of loop by closing the console that is
# running the program
This will keep the console open so you can see messages and the output
from the print() statement.
"program fails" isn't helpful unless we can figure out what is
happening. I still think that your program isn't actually getting run.
This suggestion will make a start at finding out what's going on.
[snip]
Instead of 'sleep', you could just add an input line:
print('This is a test')
input('Press Enter to finish')
Just as good! The important thing is to see if the program is actually
getting launched. If the Python program fails to run then the console
window won't appear for more than a brief flash. If it runs but there
is some problem about creating/opening that file, well, this program
doesn't try. We're just trying to see if a .py file gets launched in
the way that is being used. We need to know if the launching process is
failing or that new file is bombing out somehow.
--
https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
On 12/5/25 6:36 PM, Chris Angelico via Python-list wrote:
> On Sat, 6 Dec 2025 at 12:33, Michael Torrie via Python-list
> wrote:
>> Starter = open("HLYlog.txt","w");
>> filepath = Starter.name
>
> Isn't that just...
>
> filepath = "HLYlog.txt"
yup. But did you miss the os.path.abspath() bit?
--
https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
Op 5/12/2025 om 21:03 schreef Em: Copy that file onto a folder in a WIN10 computer which uses Python 3.13 and copy it again onto a folder in a WIN11 computer that runs Python 3.14.1 Double-click the filename in the folder on the WIN10 computer. It executes the program and the text file is created. Double-click the filename in the folder on the WIN11 computer and it fails, no text file is created. No error statement is generated. The strange thing here is that, on the WIN11 computer, I right-click and choose "Edit with IDLE" option. The file code is shown and I press F5. The program runs properly and the text file is created. Of course, IDLE does not show an error report on a working program. There's probably an issue with the way Windows launches the Python interpreter (or tries to do so) when double-clicking the script. Perhaps there is no corresponding association on your Windows 11, or maybe it points to another interpreter. To figure this out, open a command prompt and in it cd to the directory where your script is (the easiest way to do that: put your cursor in the address bar in Explorer, replace the whole text that was there with "cmd" (without the quotes), then press enter. That should open a command prompt with the correct working directory. Type the filename of your script, including the extension, the press enter. What happens? Does this work, or is there an error? If so, what's the error message? If that didn't work, type "py " (without the quotes). What happens? Does this work, or is there an error? If so, what's the error message? -- "The reasonable man adapts himself to the world. The unreasonable man persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw -- https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
On 12/5/25 5:12 PM, Em wrote:
> Ok, using "Open with Python" , the program fails on both computers.
> Still, double-click the filename on the WIN10 computer and the program
> works.
> While, double-click the filename on the WIN11 computer and the program
> fails.
Here's a test script for you that will pop up a windows message box to
tell you where the file it is writing is truly located. See what it
says on the two platforms. Yes it's a few lines of code, but it will
surely tell you where the problem is.
import os
import ctypes
Starter = open("HLYlog.txt","w");
filepath = Starter.name
# following should be all on one line
ctypes.windll.user32.MessageBoxExW(None, os.path.abspath(filepath),
"True file path", 0x4)
--
https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
On 12/5/2025 7:12 PM, Em wrote:
Ok, using "Open with Python" , the program fails on both computers.
Still, double-click the filename on the WIN10 computer and the program
works.
While, double-click the filename on the WIN11 computer and the program
fails.
Then set up the file association for .py files in Settings/Default apps.
And write a different test program, one that will stay around so you can
see error messages. Perhaps (untested)
from time import sleep
print('this is a test')
sleep(10) # sleep 10 seconds
# or
# while True:
# sleep(10) # Break out of loop by closing the console that is
# running the program
This will keep the console open so you can see messages and the output
from the print() statement.
"program fails" isn't helpful unless we can figure out what is
happening. I still think that your program isn't actually getting run.
This suggestion will make a start at finding out what's going on.
-Original Message-
From: Thomas Passin
Sent: Friday, December 5, 2025 4:34 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION
On 12/5/2025 3:03 PM, Em wrote:
Alright, Alright, Alright...
Alright.
These responses push much more sophisticated explanations than the
question asked. This involves only one line of code that creates an empty
text file.
No other code is involved or needed.
Before responding, please run this test:
Create a .py file that contains the line:
Starter = open("HLYlog.txt", "w")
Copy that file onto a folder in a WIN10 computer which uses Python
3.13 and copy it again onto a folder in a WIN11 computer that runs
Python 3.14.1
Double-click the filename in the folder on the
WIN10 computer. It executes the program and the text file is created.
Double-click the filename in the folder on the
WIN11 computer and it fails, no text file is created.
No error statement is generated.
The strange thing here is that, on the WIN11 computer, I right-click
and choose "Edit with IDLE" option. The file code is shown and I
press F5. The program runs properly and the text file is created. Of
course, IDLE does not show an error report on a working program.
The medical program that I wrote, and have used for 20 years, works on
the WIN10 computer. I now want to copy it to the WIN11 computer and it
consistently fails on this line.
The change from WIN10 Python 3.13 to WIN11 Python 3.14 is the only
difference I can see.
You have been mixing up two things, and it's confusing to people who want to
help:
1. Running a .py file by double-clicking the .py file name in Windows
Explorer; 2. Whether or not your program works using this Python install,
when run from the command line in a Console.
Kindly try to run the program with Python from the command line. By that I
mean some variation of "py your_program.py". Of course, you first need to CD
to its directory; otherwise you have to include the full path. See if it
creates the file it's supposed to. If it does, delete the created file, and
try to run the program from the console just using the file's name,
*without* prefixing it with "py", "python" or whatever you used to run it
when it succeeded. You should see a new console flash up for a moment then
close and vanish. See if the file was created.
Running by typing the .py file name by itself should will launch it the same
way it would be launched when you double click on the file name.
If the file was created when you ran your file with the python executable,
that verifies the program ran and functions. Since it works in IDLE, that
should succeed. Then if it fails when typing just the bare program name,
that would show that the file association for .py files isn't set up.
Unfortunately, the new console doesn't stay visible long enough to see any
error messages and you have to work around that fact to make sure of what is
going on.
Another way to check is to right-click on your .py file in Windows Explorer,
and go down to the "Open With" menu item. The first name in that list should
be some variation of "Python (Default)". If that's not the case, you need to
set up the file association using the Settings/Default apps settings page,
as I mentioned in an earlier post.
I suspect that the file association hasn't been set up. That was the case
on my Windows 11 computer too.
-Original Message-
From: Michael Torrie via Python-list
Sent: Friday, December 5, 2025 1:18 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION
On 12/4/25 10:47 PM, Em wrote:
Starter = open("HLYlog.txt", "w")
Thoughts appreciated.
-That's a relative path. Are you sure that the current working
directory is what -you expect? It's generally better to work with
absolute paths.
Relative or not, I can't see how that could possibly make any difference.
You don't? Why? The key word is "working directory." How do you know
what the working directory is? If you start a program using a shortcut
link, the link can specify an
Re: A switch somewhere, or bug? CORRECTION
On 06/12/2025 00:52, Thomas Passin wrote:
On 12/5/2025 7:12 PM, Em wrote:
Ok, using "Open with Python" , the program fails on both computers.
Still, double-click the filename on the WIN10 computer and the program
works.
While, double-click the filename on the WIN11 computer and the program
fails.
Then set up the file association for .py files in Settings/Default
apps. And write a different test program, one that will stay around so
you can see error messages. Perhaps (untested)
from time import sleep
print('this is a test')
sleep(10) # sleep 10 seconds
# or
# while True:
# sleep(10) # Break out of loop by closing the console that is
# running the program
This will keep the console open so you can see messages and the output
from the print() statement.
"program fails" isn't helpful unless we can figure out what is
happening. I still think that your program isn't actually getting run.
This suggestion will make a start at finding out what's going on.
[snip]
Instead of 'sleep', you could just add an input line:
print('This is a test')
input('Press Enter to finish')
--
https://mail.python.org/mailman3//lists/python-list.python.org
RE: A switch somewhere, or bug? CORRECTION
Alright, Alright, Alright...
Alright.
These responses push much more sophisticated explanations than the question
asked. This involves only one line of code that creates an empty text file.
No other code is involved or needed.
Before responding, please run this test:
Create a .py file that contains the line:
Starter = open("HLYlog.txt", "w")
Copy that file onto a folder in a WIN10 computer
which uses Python 3.13 and copy it again onto a folder
in a WIN11 computer that runs Python 3.14.1
Double-click the filename in the folder on the
WIN10 computer. It executes the program and the
text file is created.
Double-click the filename in the folder on the
WIN11 computer and it fails, no text file is created.
No error statement is generated.
The strange thing here is that, on the WIN11 computer,
I right-click and choose "Edit with IDLE" option. The file
code is shown and I press F5. The program runs properly
and the text file is created. Of course, IDLE does not
show an error report on a working program.
The medical program that I wrote, and have used for 20 years,
works on the WIN10 computer. I now want to copy it
to the WIN11 computer and it consistently fails on
this line.
The change from WIN10 Python 3.13 to WIN11 Python 3.14
is the only difference I can see.
-Original Message-
From: Michael Torrie via Python-list
Sent: Friday, December 5, 2025 1:18 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION
On 12/4/25 10:47 PM, Em wrote:
>> Starter = open("HLYlog.txt", "w")
>>
>> Thoughts appreciated.
>
> -That's a relative path. Are you sure that the current working
> directory is what -you expect? It's generally better to work with
> absolute paths.
>
> Relative or not, I can't see how that could possibly make any difference.
You don't? Why? The key word is "working directory." How do you know what
the working directory is? If you start a program using a shortcut link, the
link can specify any arbitrary directory. If you start it from idle, idle
sets the working directory. If you double click the py file, the pylauncher
sets the working directory. All could be and in fact are different. If you
always want it to open that file in the same directory as the script, then
you can use code such as the following:
import os
# Get the absolute path of the current python file we're running
current_file_path = os.path.abspath(__file__)
# Get the directory of the current file
current_directory = os.path.dirname(current_file_path)
print(f"The directory of the current file is: {current_directory}")
(disclaimer, suggested by AI, verified by me to be correct).
--
https://mail.python.org/mailman3//lists/python-list.python.org
--
https://mail.python.org/mailman3//lists/python-list.python.org
Re: A switch somewhere, or bug? CORRECTION
On Sat, 6 Dec 2025 at 12:33, Michael Torrie via Python-list
wrote:
> Starter = open("HLYlog.txt","w");
> filepath = Starter.name
Isn't that just...
filepath = "HLYlog.txt"
?
ChrisA
--
https://mail.python.org/mailman3//lists/python-list.python.org
