On Thu, Jun 24, 2010 at 10:13, Alan Gauld <alan.ga...@btinternet.com> wrote: > > "Richard D. Moores" <rdmoo...@gmail.com> wrote > >> How can I prevent >> >> Traceback (most recent call last): >> File "C:/P31Working/prime_to_biggest_prime_tutor3.py", line 45, in >> <module> >> sys.exit() >> SystemExit >> >> from printing? Or isn't using sys.exit() a good idea? > > Steven has already given you an answer to that although > I'd add that I have no problems using sys.exit() in top level code. > Just don't use it inside a function. Either raise an exception > or return a value. > > If you are using it at the top level you may be running your code > inside an IDE like IDLE or Pythonwin which always catches > sys.exit(). That's OK, it's intended to print that message rather > than exit so that you can debug the code if necessary, but it > won't do it if you run the code from the OS prompt it will just > exit silently as expected.
Thanks, Alan. And thanks also to Steven. I think I much prefer accomplishing an exit by a function return, as I do in <http://tutoree7.pastebin.com/QtAAtATd>, but if I wanted to use sys.exit() in a script (but not in a function) I run inside IDLE or Wing, how do I suppress the message? I'd just like to get that nailed down. Dick _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor