For a simple python script that does not start any threads or fork of any processes, what is the difference between the simplicity of executing until the end of the script and the explicit call to quit (), exit () or sys.exit ()?
i.e. What's the difference between
def main():
print("Done doing stuff")
if __name__ == '__main__':
main()
and
import sys
def main():
print("Done doing stuff")
sys.exit()
if __name__ == '__main__':
main()
I ask about this because I had some problems with garbage collection at the end of the script (exceptions raised from __del__, apparently, due to the order in which things are cleared) without an explicit call exit()and adding an explicit exit()one seems to fix these problems . Or at least none of these exceptions will be printed after the call exit(), perhaps they are simply disabled.