[wxPython-mac] Re: [Pythonmac-SIG] Wanted: working example of CFBundleTypeRole Shell

Kevin Altis altis@semi-retired.com
Fri, 8 Mar 2002 12:08:24 -0800


> From: Kevin Ollivier
>
> The default behavior on Windows is to have a terminal window for .py, and
> suppress it with .pyw. I think this works. We may need to control
> Terminal.app to make this happen... I'll have to look into it. However, I
> have to say that the terminal window issue on Windows is not very reliable
> because the shell closes as soon as execution stops - which isn't very
> helpful for debugging purposes. (Nothing to do with Python, a dumb default
> in Windows.) As a result, on Windows I always open up a DOS window when I
> want to view terminal output as well. On OS X, you can use the Console.app
> utility to view any stderr (and stdout?) messages that occurred since the
> start of the session, so anyone wanting to debug has this option as well.

Chances are on Windows you want to pass the -i command-line option to
Python.

# -i     : inspect interactively after running script, (also
PYTHONINSPECT=x)
#         and force prompts, even if stdin does not appear to be a terminal

When the app ends, you'll still be in the interpreter (Ctrl+Z to exit). In
addition, if there is a syntax error, your console window won't disappear,
you'll be left in the interpreter with a message telling you where the
problem is.

I'm working on this very issue right now trying to get scripts to launch as
detached sub-processes on both Windows and Linux. The resourceEditor in
PythonCard can run a script just fine and that has been working for a while
using os.system on Linux and os.popen on Windows with 'start'. The
difficulty arises when the script has a syntax error. In that case, you want
to run with the interpreter or have some other method to catch the
traceback. Once a wxPython app is in the main event loop it doesn't matter
because an exception won't kill the event loop, but it does when the syntax
error prevents the main event loop from starting.

I'm not happy with the launch with interpreter solution I have and will
probably post on c.l.py later today, so I won't clutter this thread with any
more details. If you're interested, email me directly.

ka