I am aware of the die()
command in PHP which exits a script early.
How can I do this in Python?
You can also use simply exit()
.
Keep in mind that sys.exit()
, exit()
, quit()
, and os._exit(0)
kill the Python interpreter. Therefore, if it appears in a script called from another script by execfile()
, it stops execution of both scripts.
See "Stop execution of a script called with execfile" to avoid this.