File: class/Workbook/Examples/Lecture8/helloexc.py

myException = 'Error'     # string object

def raiser1():
    raise myException, "hello"     # raise, pass data

def raiser2():
    raise myException              # raise, None implied

def tryer(func):
    try:
        func()
    except myException, extraInfo:
        print 'got this:', extraInfo



[Home page] Books Code Blog Python Author Train Find ©M.Lutz