raise ZeroDivisionError : raise « Statement « Python Tutorial






import sys

def exc_thrower(x) :
    z = 0
    try :
        z = 100 / x
    except :
        print "Error encountered in exc_thrower: "+repr(sys.exc_type)
        raise

exc_thrower(0)
exc_thrower("Hello")








3.15.raise
3.15.1.raise Statement: raise [SomeException [, args [, traceback]]]
3.15.2.Raise value error
3.15.3.Raise error from function
3.15.4.raise ZeroDivisionError
3.15.5.raise exception-type