I have written a program that needs to quit if it encounters a certain event.
I can raise exceptions, but how do I raise a fatal exception that ends the program?
I have written a program that needs to quit if it encounters a certain event.
I can raise exceptions, but how do I raise a fatal exception that ends the program?
Exceptions are a part of the program flow. They are not intended to end a program, but to indicate an error going realtime and let the program handle it.
Use sys.exit()
to end programs during runtime.