delayed sys.exit?

Stephen Hansen apt.shansen at gmail.com
Wed Jul 29 16:36:32 EDT 2009


>
> In the attached  http://www.nabble.com/file/p24726902/test.py test.py
> code,
> it appears that additional statements execute after the call to
> sys.exit(0).
> I'll be grateful if anyone can shed light on why this is happening.  Below
> is a copy of some sample I/O.  Note that in the last case I get additional
> output after what should be the final error message.
>

A bare "except:" catches ALL exceptions; including SystemExit which is
generated by
sys.exit. And KeyboardInterrupt, too. That's why its basically a bad
idea to use bare excepts unless you really, really, really need to.
Try 'except Exception' instead. SystemExit and such do not inherit
from Exception.

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090729/89114fbe/attachment.html>


More information about the Python-list mailing list