do_magic() # Throws exception, doesn\'t execute do_foo and do_bar
do_foo()
do_bar()
try:
do_mag
you could try a nested ´try´ loop, alltho that might not be as elegantly pythonic as you might want. the ´lambda´ solution is is also a good way to go, did not mention because it was done in the previous answer
edit:
try:
do_magic()
finally:
try:
do_foo()
finally:
try:
do_bar()
except:
pass
edit 2:
well damnnit, this answer just got posted seconds beforehand again :|