Stop Python from exiting upon error in Windows

Robert at AbilitySys.com Robert at AbilitySys.com
Tue Jul 15 00:01:06 EDT 2003


Thanks! I'm getting closer to what I want, but it raises two questions:

1. Is there an IDLE keystroke to indent a block of code? (just putting try:
at the start of my program causes an error, expecting an indented block to
follow which is my entire program!)

2. Is there a way to tell the environment I'm running under (python
interpreter, IDLE window, or other)? I'd like to put a pause at the end of
my program if and only if I'm running under the python.exe DOS-like
program...

- Robert

"Peter Hansen" <peter at engcorp.com> wrote in message
news:3F136BEA.5B56562 at engcorp.com...
> Tom Plunket wrote:
> >
> > Or- catch the error in your mainline, and do a sys.raw_input()
> > call on exception.
>
> Tom meant just "raw_input()", which is a builtin, rather than
> sys.raw_input which does not exist, of course.
>
> To answer your question in the other reply, yes, you can
> nest exceptions.  If you have a try/except and the raw_input
> in the except, however, you won't see any exception traceback
> printed at the console so you'll need something like the
> traceback module and one of the functions from it, like
> traceback.print_exc().
>
> -Peter






More information about the Python-list mailing list