On Mon, Jul 30, 2012 at 2:44 PM, Albert-Jan Roskam <fo...@yahoo.com> wrote:

> *From:* Tino Dai <obe...@gmail.com>
>
> *To:* nz*tutor pythonzzz <tutor@python.org>
> *Sent:* Monday, July 30, 2012 6:56 PM
> *Subject:* [Tutor] finally without try or except
>
> 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.
>
> Any hints?
> Tino
>
> ===> Hi, perhaps it's overkill, but you could define your own __exit__
> (and __enter__) method so you can use a 'with' statement (context manager):
> http://docs.python.org/release/2.5.2/lib/typecontextmanager.html
>
> That's actually I good idea, and will take a look at this because it will
expand my python knowledge. I'm not sure if I want to go down this path
because of the above stated reasons. -T
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to