preserve exception within try .. finally

Brian Alexander brian094 at sympatico.ca
Fri Oct 10 15:57:13 EDT 2003


Hello;

I'm curious to know how people preserve exceptions that arise in a try 
.. finally block. Consider this example:

try:
   getResource()
   doSomething()
finally:
   alwaysFreeResource()

If an exception occurs in doSomething(), the resource is freed anyway -- 
which is good. How can I keep the exception 'raised' for another 
try-finally/except to deal with? Does this problem reflect an error in 
the way I am approaching the problem?


Many thanks,

Brian.





More information about the Python-list mailing list