At 03:56 PM 11/1/2006, Andreas Kostyrka wrote: >Am Mittwoch, den 01.11.2006, 15:43 -0800 schrieb Dick Moores: > > At 12:14 AM 10/31/2006, Alan Gauld wrote: > > > > >"Dick Moores" <[EMAIL PROTECTED]> wrote > > > > I'd like to know how to use sys.exit() to quit a program. > > > > > > > > > >I see that you already figured that out. > > >You can also quit by raising SystemExit, which is > > >what sys.exit does... but you don't need to import sys... > > > > I'm afraid I don't know what you mean. How do I raise SystemExit, and > > why don't I need to import sys? > >raise SystemExit(2) > >is equal to sys.exit(2) (actually sys.exit(2) just raises SystemExit(2))
OK, that works well. But why the 2? BTW at the command line, "raise SystemExit(2)" produces a completely silent exit. In Win IDE I get "SystemExit: 2". With IDLE: Traceback (most recent call last): File "E:\Python25\dev\1unitConversion5a.py", line 425, in <module> main() File "E:\Python25\dev\1unitConversion5a.py", line 413, in main s = formatAndCheckStringFromUser(s) File "E:\Python25\dev\1unitConversion5a.py", line 342, in formatAndCheckStringFromUser s = stripResponseAndCheckForUserRequestForHelpOrToQuit(s) File "E:\Python25\dev\1unitConversion5a.py", line 253, in stripResponseAndCheckForUserRequestForHelpOrToQuit raise SystemExit(2) SystemExit: 2 If I can manage to use "break", all 3 exits are silent. Why is it wrong to use "break" to exit? Dick Moores Dick Moores _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor