[Pythonmac-SIG] can't exit module
Jack Jansen
jack@oratrix.nl
Fri, 08 Dec 2000 13:11:41 +0100
> Although I import the sys module the command sys.exit() doesn't work.
> Here is the most simple example:
> import sys
>
> a= 7
> while a<10:
> print 'this is the while loop'
> a=a+1
> if a==9:
> print 'exiting'
> sys.exit()
>
> I always get the same error:
> SystemExit:
> Traceback (innermost last):
> File "Script 1", line 9, in ?
> sys.exit()
You're right: sys.exit() doesn't work in the IDE. In the raw interpreter it
works fine, and indeed exits the interpreter, but in the IDE it is unclear
what it should do.
On the one hand exiting the IDE is a possible solution, and seems to be what
you expected. On the other hand exiting may not be what you want: if you're
running a script that was written for Unix (which doesn't have an IDE) calling
sys.exit() will be the normal way of terminating the script, and you wouldn't
want to terminate the IDE in that case.
I'm not sure. Maybe there should be a preference telling the IDE what to do on
sys.exit, either the current behaviour or exiting? A side issue is that the
message "SystemExit" is rather obscure. Maybe it should be replaced with
"Script called sys.exit()" or something a bit more descriptive.
--
Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm