raise Exception Syntax question

chris csad7 at yahoo.com
Fri Apr 9 17:16:57 EDT 2004


hi,
i am wondering if there is a difference between the following 
possibilities to raise an exception, the first seems to be in all the 
books about python i have but the second gives the same result at least 
under Python 2.3.3:

 >>> import exceptions
 >>> e = exceptions.Exception


 >>> raise e, "MESSAGE"
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
Exception: MESSAGE


 >>> raise e("MESSAGE")
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
Exception: MESSAGE


is there a preferable way?

thanks
chris




More information about the Python-list mailing list