break
Exit only from a loop and does not terminate the application, it is less than return
. Up to return
can terminate the application when it is in the same function as the entry point.
sys.exit()
(From module sys
);
Terminates the application by throwing an exception ( SystemExit
) that can be handled at some point and all process termination, including resource release is performed before completion. It is considered that its use is not ideal and should only be called in very specific cases where you fully understand what you are doing and need exactly this immediate termination solution. I personally do not think so bad so if you really do not have anything else to accomplish, at least in well-done architectures that have no dependence on a specific shutdown. Use it preferably.
os._exit()
(From module os
);
Close the execution immediately without giving you the chance to do anything else, not even the release of resources.
exit()
Same as sys.exit()
, but it is not intended to be used. I'm not sure why, but I believe that functions that do not belong to modules become ambiguous. Use in many simple codes or in REPL when importing a module can be worse. This is the language problem that starts out to be script and then changes to be more than this.
quit()
Only one nickname for the previous function. Clear violation of "just have a way to accomplish something".
There is nothing kernel there, just that os.exit()
is a shutdown call that probably asks the OS to terminate without further ceremony. There is no link to any routine. This seems to be a misunderstanding. It's a function like any other you call at some point in the code and it does something, in case that something is closing the application.