On Wed, 25 May 2016, Alex Hall wrote:

You're not missing anything; I wasn't clear. I wasn't sure if raise or
sys.exit(1) were the preferred ways, or if there was some other way I
didn't know about.

If you're aborting because of the exception after unsuccessfully trying to handle it, you can always just use "raise" with no operands, which will re-raise the underlying exception. That's what I usually do:

try:
    1/0
except ZeroDivisionError:
    print "oops."
    raise

prints:

oops.
Traceback (most recent call last):
File "[...]\test.py", line 2, in <module>
    1/0
ZeroDivisionError: integer division or modulo by zero

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to