Exceptions
Peter Hansen
peter at engcorp.com
Sun Feb 2 01:11:47 EST 2003
Tetsuo wrote:
>
> Mark's example?
Without context, I almost didn't catch that as a question directed
to me...
Mark McEahern posted an answer which I read before I posted my
reply which referred to it. Maybe it hadn't reached you yet,
and I should apologize for not quoting the content. What he
wrote was this (with apologies to Mark for the copyright
violation :-) :
"""
Subclass your exception from Exception; e.g.,
class MyException(Exception):pass
def dostuff():
raise MyException
try:
dostuff()
except MyException, e:
print "We caught %s" % e
"""
-Peter
More information about the Python-list
mailing list