python sys.exit()
1 import sys 2 3 try: 4 s = raw_input('Enter something --> ') 5 except EOFError: 6 print '\nWhy did you do an EOF on me?' 7 sys.exit() # exit the program 8 except: 9 print '\nSome error/exception occurred.' 10 # here, we are not exiting the program 11 12 print 'Done'
1 exit([status]) 2 3 Exit the interpreter by raising SystemExit(status). 4 If the status is omitted or None, it defaults to zero (i.e., success). 5 If the status is numeric, it will be used as the system exit status. 6 If it is another kind of object, it will be printed and the system 7 exit status will be one (i.e., failure).