Re: A switch somewhere, or bug? CORRECTION

Thomas Passin <[email protected]> Sat, 6 Dec 2025 08:43:16 -0500
Newsgroups gmane.comp.python.general
Message-ID <[email protected]>
On 12/6/2025 2:22 AM, Michael Torrie via Python-list wrote:
> On Sat, Dec 6, 2025, 00:04 Chris Angelico <[email protected]> wrote:
> 
>> On Sat, 6 Dec 2025 at 15:52, Michael Torrie via Python-list
>> <[email protected]> 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
>>>> <[email protected]> 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.

The real point is that if the file doesn't get created, you don't know 
whether the program failed or it was never run. The console will flash 
into existence and then go away so quickly that one can't read any text 
that may have been emitted.

If you really think that the program ran but failed to create the file, 
then put the file creation in try..except, in the except block print a 
message about what happened, and then pause the program in one of the 
ways posted earlier so you can read the message.

Continuing to run the program the same way without diagnostics isn't 
going to help.