There are objects whose repr() is not the same
as what gets printed out when you apply the
print statement to them. Usually these are
complex objects like exceptions.
Example:
>>> import smtplib
>>> server=smtplib.SMTP("smtp.yourisp.com")
>>> try:
server.sendmail("[EMAIL PROTECTED]",
"[EMAIL PROTECTED]","message")
except smtplib.SMTPRecipientsRefused, senderrs:
exc_obj=senderrs
>>> repr(exc_obj)
'<smtplib.SMTPRecipientsRefused instance at 0x00EA7C60>'
>>> print exc_obj
{'[EMAIL PROTECTED]': (550, 'Verification failed for <[EMAIL
PROTECTED]>\nunrouteable mail domain "in88validdomain.com"\nSender
verify failed')}
Question:
Is there a way to somehow put the output of 'print exc_obj' into
a string?
--
http://mail.python.org/mailman/listinfo/python-list