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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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():Other possibilities:
thread.interrupt_main().