On 1/1/21, Sibylle Koczian <nulla.epist...@web.de> wrote: > > But that doesn't help, if the script raises an exception. In that case > the input() call won't be reached and the window will close anyway > before you could see anything. And in a script with errors that's even > worse. Same effect with the "run" window.
The simplest, best option is running the script from an existing shell that owns the console session. That said, here are a couple alternatives to calling input() in a `finally` block. If you have .py files associated with the py launcher, for testing you can use a shebang such as `#!/usr/bin/python3 -i`. The "-i" option enters interactive mode after executing the script, even if there's an unhandled Python exception. Entering interactive mode won't work if the process crashes at a low level. To handle that, you can instead spawn a child process in the console session that waits forever. A good candidate is "waitfor.exe", which opens a mailslot and waits for it to be signaled. For example: import subprocess subprocess.Popen('waitfor.exe ever') This process will still be attached to the console session after Python exits. You can kill it by closing the console window, or by running `waitfor.exe /si ever` to signal it. -- https://mail.python.org/mailman/listinfo/python-list