Re: A switch somewhere, or bug? CORRECTION

"Peter J. Holzer" <[email protected]> Sat, 6 Dec 2025 18:55:47 +0100
Newsgroups gmane.comp.python.general
Message-ID <sisj6q66g6uj3yotjfbfaymd4ezpswatsspagsbj4ovkt4sskb@utsyfmory3ex>
On 2025-12-04 18:03:34 -0500, Em wrote:
   ^^^^^^^^^^
   Weird. That was before most of the thread (and the message wasn't
stuck in a moderation queue), yet it seems everybody ignored this message. .
Probably because it isn't actually part of the thread, but ...

> On my computer: Win11, Python 3.14.1
> 
>  
> 
> Double-click and run on the file".  You will see the first two lines
> execute.
> 
> The screen will show "Start" and "Starter File".

Good. So we know that the program is executed.

> Hit <Enter> to resolve the
> pause statement and the program crashes when it tries to create the
> "HLY-LOG5" file. The last line, "End" is not printed. No file is created.

So the next step is to find out why it isn't executed. First print the
working directory:

import os
print("Start")
print("working directory:", os.getcwd())
input("   Starter file")

then wrap the open in a try/except block:

try:
    Starter = open("HLY-LOG5.txt","w")
except Exception as e:
    print("Error: {e}")
input("End")

This should now tell you in which directory the program is actually
trying to create the file and why id didn't work.

        hjp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | [email protected]         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmk0bh0ACgkQ8g5IURL+
KF1ydRAAlJvC7cufGoVtdcTjChprCoUJNvBsyZfwupQHTrGPGt14IQLxxGlSx7zx
v8AntPuifcxMlj0K4MSaAT027I+xQekHV1W2IDQN2sgqCG/8BTMDcGku7ykZKmPQ
NqfjS/ixdJgFnryAXLkDy0oWwtEZ441aqV24mRZqDjY/qVuIVPgK4SvqeCV/CtAR
oWYBe0PFfxl4RqcgQb7ZkRaT8f5AFMjvZDzryDHupXAlzA1mOmmtH0+l/1keaCWA
78kPRNaJ1tEqpYFZDOTdQ38qmt4Wx7cov6goZ/MgO9CVReLmc1pAEoSycOZC1OYJ
LXm3V8DYftFB0BP614dhBgdtHuA3xj8vTwmOs6jx6dmtcRbsn77JQCNASBUvaeqd
wns64td4Y8dFFM+ZWAqgGa7sRQZRnxzrzzjclVm6/JoxAKv4eQBxf2AYXSvGNjm3
s/p9GtMZT2HpKslRby3ImgJbZ3YaP8l68PD4e6Ot+0A1ZA2oJ4RZpG3k6Q77X+En
gMvs8rduVBEmoeMkPpbw/dbFSSwRFwS4P5o/Rp53OGWREl4wrCEDF3Xnzz8tYrSu
MHM2R/0Vo0NH0zxC/EBhkgjRw4HkYHUAx5QnkWvt9jhJuURdyqhJqDR923edIJTw
6MJE87tR9RC/CwmSeXBztClYrHQnLeXdjR0JuZf7HF1ONPqxhlQ=
=fUlq
-----END PGP SIGNATURE-----