As has been pointed out, an unhandled AssertionError, as thrown by assert, should already stop your script.
assert always fails if the condition being tested doesn't evaluate to True. That is as long as you do not run python with optimizations enabled (-O flag), in which case it will not throw an AssertionError (as assert statements are skipped in optimized mode).
So
def assert_exit(condition, err_message):
try:
assert condition
except AssertionError:
sys.exit(err_message)
Should be what you want, if you absolutely want to call sys.exit() and use assert; However this
assert condition
will stop your script just as fine and provide a stacktrace, which saves you the trouble of entering a custom error message each time you call assert_exit, and points you directly to the offending party.
AssertionErrors should do the trick… why do you need an even more directexit?