ask help about raise, thank u
John Machin
sjmachin at lexicon.net
Tue Feb 26 04:44:24 EST 2002
"dongkui" <dongkui at huawei.com> wrote in message news:<mailman.1014686626.31452.python-list at python.org>...
> cGxzIGdpdmUgbWUgb25lIGV4YW1wbGUgYWJvdXQgcmFpc2Ugd2hpY2ggaGF2ZSB0aHJlZSBwYXJh
> LCBhbmQgdGhlIHRoaXJkIHBhcmEgaXMgdHJhY2ViYWNrIG9iag0KDQpsaWtlIA0KcmFpc2UgImEi
> LCAiYiIsIGMgI2MgYXMgdHJhY2ViYWNrIG9iamVjdA0KDQp0aGFuayB1DQo=
>
> --
After running the above through
repr(base64.decodestring(the_above_guff)) and wrapping lines at 40
columns:
'pls give me one example about raise whi
ch have three para, and the third para i
s traceback obj\r\n\r\nlike \r\nraise "a
", "b", c #c as traceback object\r\n\r\n
thank u\r\n'
Further translation:
para -> paragraph? No
para -> paratrooper? I see no "fee fi fo fum" material here.
para -> parameter -> argument? Aha!
Disclaimer: This is how I think the third arg is meant to be used; I
have never
actually had to do this in practice.
try:
some code which may explode
except:
exc, data, tb = sys.exc_info()
if I_can_handle_this(exc):
handle_it(exc, data)
else:
# re-raise the exception, with traceback giving the *original*
# source of the problem (somewhere inside the 'try' suite),
# not the 'raise' statement
raise exc, data, tb
Also, you would need to heed the warning in the documentation for
sys.exc_info()about circular references caused by assigning the
traceback to a local variable.
Hope this helps,
John
More information about the Python-list
mailing list