message of Exception

Steven Woody narkewoody at gmail.com
Tue Jan 6 21:56:26 EST 2009


Hi,

I am trying define an Exception as below:

class MyError(Exception):
    def __init__(self, message):
        self.message = message

And, I expect that when I raise a MyError as
    raise MyError, "my message"
the python should print a line such as
   MyError: my message

But I did not get that, I just got:
   ...
   MyError

I guess I had made something wrong with the __init__() definition, but
I can not find an answer in doc.  Please help, thanks!

-
narke



More information about the Python-list mailing list