traceback (most recent call last)file " :\code\exctools py"line in safe callee(*pargs**kargscatch everything else file " :\code\oops py"line in oops raise myerror('spam!'oops myerrorspamgot spamthe following sort of code could turn this into function decorator that could wrap and catch exceptions raised by any functionusing techniques introduced in but covered more fully in in the next part of the book--it augments functionrather than expecting it to be passed in explicitlyimport systraceback def safe(callee)def callproxy(*pargs**kargs)tryreturn callee(*pargs**kargsexcepttraceback print_exc(print('got % % (sys exc_info()[ ]sys exc_info()[ ])raise return callproxy if __name__ ='__main__'import oops @safe def test()oops oops(test( self-study examples here are few examples for you to study as time allowsfor moresee follow-up books--such as programming pythonfrom which these examples were borrowed or derived--and the webfind the largest python source file in single directory import osglob dirname ' :\python \liballsizes [allpy glob glob(dirname os sep 'py'for filename in allpyfilesize os path getsize(filenameallsizes append((filesizefilename)allsizes sort(print(allsizes[: ]print(allsizes[- :]part viiexceptions and tools