[Tutor] Stopping A Program

alan.gauld@bt.com alan.gauld@bt.com
Mon, 14 Oct 2002 17:07:23 +0100


> Once a python program is running I don't seem to be able to 
> stop it ... 

raise SystemExit

or

import sys
sys.exit()

The latter gives the option of returning an error code to 
the external environment:

sys.exit(2)

Note that these will all be caught by IDLE but when running 
the program as a standalone script will exit back to the OS.

BTW This is covered in the very first hands-on topic in my 
online tutor... :-)

HTH,

Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld