A neat trick i found in the python tutorial:
If you need to determine whether an exception was raised but don't intend to handle it, a simpler form of the raise statement allows you to re-raise the exception:
>>> try:
... raise NameError, 'HiThere'
... except NameError:
... print 'An exception flew by!'
... raise
...
An exception flew by!
Traceback (most recent call last):
File "", line 2, in ?
NameError: HiThere
For more read the Errors and Exceptions section
No comments:
Post a Comment