delayed sys.exit?

Peter Otten __peter__ at
Wed Jul 29 22:40:13 CEST 2009

Dr. Phillip M. Feldman wrote:

> In the attached
> code, it appears that additional statements execute after the call to
> sys.exit(0).

>    try:
>       # If the conversion to int fails, nothing is appended to the list:
>       Runs.append(int(strs[i]))
>       if Runs[-1] <= 0:
>          print 'ERROR: ' + str(Runs[-i]) + \
>            ' is invalid; run numbers must be positive.'
>          sys.exit(0)
>    except:

sys.exit() works by raising a SystemExit exception which is caught by the 
bare except.

As a general rule try to be as specific as possible when catching 


More information about the Python-list mailing list