Q: handling exceptions

Michael Chermside mcherm at destiny.com
Tue Sep 17 12:58:59 EDT 2002

Karsten Weinert wrote:
 > The problem is: how can I access the
 > message string of the exception?

Does this help?

Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
 >>> def raiseit():
	raise Exception, 'This is the message string'

 >>> try:
except Exception, s:
	print "Message is '%s'." % s

Message is 'This is the message string'.

-- Michael Chermside

More information about the Python-list mailing list