views:

71

answers:

2

http://docs.python.org/library/imaplib.html states that:

exception IMAP4.error
Exception raised on any errors. The reason for the exception is passed to the constructor as a string.

What does "exception is passed to the constructor as a string" mean? What would the code look like that can print the reason.

+2  A: 

Just use print str(exception).

Daniel Kluev
+1  A: 

You can specify the reason when constructing the exception yourself, and put it into a variable when catching the exception.

try:
    raise imaplib.IMAP4.error('Some exception')
except imaplib.IMAP4.error, error:
    print error
jellybean