On Sun, May 31, 2020 at 6:14 AM Mike Miller <python-id...@mgmiller.net> 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. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/CIBLVJCUKGS4BPCJDU4TE33IKWQDYEFA/ Code of Conduct: http://python.org/psf/codeofconduct/