[Tutor] Script performance: Filtering email

alan.gauld@bt.com alan.gauld@bt.com
Wed, 17 Jan 2001 10:30:44 -0000


> :try:
> :   (the body of your script)
> :except:
> :   raise # Re-raise the exception so that the program 

> Would someone please explain the last line above about re-raising the
> exception? I don't understand what that does.

It simply prevents the exception handling stopping in your except.
The exception gets passed up to the next level and if not handled 
there(or reraised again) eventually to the global handler which 
generates a Python stack dump.

Normally an except clause handles the error in toto, but using 
except makes it more like an interception whereby you add some 
behavior. You might think of it as analogous to calling a 
super class method in an OO situation.

class A:
  def foo(s):
	# whatever

class B(A):
  def foo(s):
     # something else
     A.foo(s)  # similar effect to using raise in exception handler

HTH,

Alan g.