Ernesto wrote: > Within the scope of one Python file (say myFile.py), I'd like to print > a message on ANY exception that occurs in THAT file, dependent on a > condition. > > Here's the pseudocode: > > if anyExceptionOccurs(): > if myCondition: > print "Here's my global exception message" > > > Is this functionality possible in python? If so, how?
Either wrap all your module level code in a try:.. except:.. statement, or you can replace the sys.excepthook() function with your own custom function (see http://docs.python.org/lib/module-sys.html) but that would then be called for all uncaught exceptions, even those that were raised from modules other than your myFile.py. HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list