[Tutor] Using sys.exit()

Dick Moores rdm at rcblue.com
Tue Oct 31 02:06:44 CET 2006


I'd like to know how to use sys.exit() to quit a program.

Here's a simple example:

import sys

c = 0
while True:
     c += 1
     if c > 10000:
	sys.exit()

Now, this will certainly exit, but not without a lot of extra noise. 
Is there a way to use it the way I want to? Maybe with an argument? 
I'm writing a script, which in a couple of places I can't use "break" to quit.

Thanks,

Dick Moores



More information about the Tutor mailing list