On Mon, Jul 30, 2012 at 9:56 AM, Tino Dai <obe...@gmail.com> wrote:

> Hi!
>
>      Is there anyway to execute a block of code at the end of a program in
> 2.6 regardless of what happened before eg exiting normally or died because
> of an exception?
> I was thinking about maybe a free standing finally code block or a
> decorator.
>

How about calling the entire program in a module and putting the call to it
inside a try/except block?  Then you can have your cleanup code in a
finally block at the end of all that.

Exceptions are meant to be caught.  I think what you're asking is "is there
any way to make Python ignore any bad stuff and keep running my program?"
The answer is yes: catch your exceptions.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to