message of Exception

S

Steven Woody

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top