As long as we're talking about libraries, yes.
For cli tools, on the other hand, there are definitely legitimate cases for exiting early.
For cli tools, on the other hand, there are definitely legitimate cases for exiting early.
def main()
blablabla
if foo:
return bar
...
return 8
if __name__ == “__main__”:
os.exit(main())
Of course that’s just my advice / opinion / preference, other ways are valid as well...