pythonreturnprogram-entry-point

What's the standard return value of a main function in Python?


I'm helping in a project of my course in the college and we have a script that depends on the return value of the main function of one of its modules (by main function, I mean the main()). But in that function, no value is returned: either the code has done successfully what it was supposed to do, or not. So, if there's no return statement in the function, what's the standard value to be returned if it reaches the end of the function?


Solution

  • Everything Daniel said is true, but additionally if you want to know the process' exit code, it will by default be 0 unless an uncaught exception is thrown in which case it will be non-zero. You can modify the exit code directly by invoking sys.exit.