On Sun, May 31, 2020 at 6:14 AM Mike Miller email@example.com wrote:
On 2020-05-28 18:02, Greg Ewing wrote:
If __name__ == '__main__': sys.exit(main(sys.argv[1:]))
It's not clear that exiting with the return value of main() is the most Pythonic thing to do -- it's more of a C idiom that
If you'd like a script to be uhh, highly-scriptable, returning one of the os.EX_* status codes can be useful to communicate back to the calling shell what happened.
First catch the exceptions, convert to the appropriate status code, then return at the end.
OR! You could just do nothing. And then, if SystemExit is raised, Python will return that exit code to the calling process (whether it's a shell or not). Python even provides a convenient function sys.exit for raising SystemExit with a specific code...
Don't catch what you can't deal with.