Possible Duplicates:
Programatically stop execution of python script?
Terminating a Python script
I want to print a value, and then halt execution of the script.
Do I just use return?
Possible Duplicates:
Programatically stop execution of python script?
Terminating a Python script
I want to print a value, and then halt execution of the script.
Do I just use return?
You can use return inside the main function in you have one, but this isn't guaranteed to quit the script if there is more code after your call to main.
The simplest that nearly always works is sys.exit()
:
import sys
sys.exit()
Other possibilities:
thread.interrupt_main()
.