exception handling

Mage mage at mage.hu
Wed Apr 20 08:33:56 EDT 2005


       Hello,


def error_msg(msg):
    sys.exit(msg)

try:
    do_something()
    if value != my_wish:
       error_msg('Invalid input')
except:
    print "Fatal IO or Network error"

This doesn't work because sys.exit raises an exception.

I know that I can define exception types after except, but there might
be many. Also I know I can write:
except:
    if str(sys.exc_info()[0]) == 'exceptions.SystemExit':
        raise

But honestly I would like simething like that:

except (!SystemExit):

Is this possible somehow?

       Mage



More information about the Python-list mailing list