sys.exit
Donn Cave
donn at u.washington.edu
Mon Apr 24 18:29:48 EDT 2000
Quoth Chuck Esterbrook <echuck at mindspring.com>:
| The short question:
|
| If I catch a SystemExit exception (because of an invocation of
| sys.exit(code)), how do I examine the argument to sys.exit()?
...
| Upon printing the "excInfo" tuple I get:
|
| (<class exceptions.SystemExit at 80afc70>, <exceptions.SystemExit instance at 8110f58>, <traceback object at 811f540>)
|
| And the attributes of the SystemExit instance are:
|
| ['__doc__', '__init__', '__module__']
|
| I don't know how to get my hands on the exit code.
That's not the instance you're looking at there, but the class, so
that's kind of a red herring. The instance has a 'code' attribute
for you.
So you need something like
eclass, einstance, etrace = sys.exc_info()
if eclass == SystemExit:
if einstance.code == 0:
self._errorOccurred = 0
Donn Cave, University Computing Services, University of Washington
donn at u.washington.edu
More information about the Python-list
mailing list