Can I get the exit code "n" passed to sys.exit(n) ?
gagsl-py2 at yahoo.com.ar
Tue Apr 10 22:35:22 CEST 2007
En Tue, 10 Apr 2007 15:15:57 -0300, Yujo <yujorodrigues at gmail.com>
> In the following code of the finish() function, is there any way to
> get the exit code passed to sys.exit() ?
> def finish() :
> RETURN_CODE_FROM_SYS_EXIT = ???? # how can I get it ?
> if RETURN_CODE_FROM_SYS_EXIT = 0 :
> # process ended OK
> else :
> # process ended with some error
> # execute something
> # this is my main program....
Uhm, I think you can't, unfortunately (at least on 2.4; I don't have the
2.5 sources at hand).
But you can instead wrap your main function with a try/except SystemExit:
except SystemExit, exitcode:
More information about the Python-list