Exception and finally question
Gerhard Häring
gh at ghaering.de
Thu Apr 24 19:06:42 EDT 2003
Tung Wai Yip wrote:
> Hello,
>
> How to I access the exception object in a handler?
>
> try:
> raise NameError, 'HiThere'
> except NameError:
> #how to print the message 'Hi There' here?
>
> Why except and finally can't be used together? I like to log a error
> message if an exception is throw. And I a file to be guaranteed to be
> close. What can't I do them together?
try:
try:
...
except ...:
...
finally:
...
HTH,
-- Gerhard
More information about the Python-list
mailing list