Handle SystemExit exception

asit lipun4u at gmail.com
Sun Feb 1 04:27:26 EST 2009


My program contains some sys.exit(1) and when its executed an
exception known as SystemExit is thrown.

I tried to handle bu using following code snippet

if __name__ == "__main__":
    try:
        main()  #main contains sys.exit(1)
    except KeyboardInterrupt:
        print "aborted by user"
    except SystemExit:
        pass

But it does not work.

Can anyone help me out ???

Though KeyboradInterrupt is handled, but why SystemExit is not
handles ????

Regards
Asit Dhal



More information about the Python-list mailing list