Re: try...finally is more powerful than I thought.
From: Bob Gailer (bgailer_at_alum.rpi.edu)
Date: 11/10/03
- Next message: Tim Churches: "Re: Re: Rekall and associated software go 100% GPL"
- Previous message: David M. Wilson: "Re: raw string from mmap.read() possible?"
- In reply to: Alan Kennedy: "Re: try...finally is more powerful than I thought."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 09 Nov 2003 16:02:07 -0700 To: Alan Kennedy <alanmk@hotmail.com>, python-list@python.org
At 07:51 AM 11/7/2003, Alan Kennedy wrote:
>[Brian Kelley]
> > How is [try..finally] working internally? Does
> > the finally get executed when try code block goes out of scope? This
> > would happen during a return or an exception which could explain the
> > magic.
>
> >From the Python Language Reference
>
>http://www.python.org/doc/current/ref/try.html
>
>"""
>The try...finally form specifies a `cleanup' handler. The try clause
>is executed. When no exception occurs, the finally clause is executed.
>When an exception occurs in the try clause, the exception is
>temporarily saved, the finally clause is executed, and then the saved
>exception is re-raised. If the finally clause raises another exception
>or executes a return or break statement, the saved exception is lost.
>A continue statement is illegal in the finally clause. (The reason is
>a problem with the current implementation - this restriction may be
>lifted in the future). The exception information is not available to
>the program during execution of the finally clause.
>"""
Which is followed by """When a return, break or continue statement is
executed in the try suite of a try...finally statement, the finally clause
is also executed `on the way out.' A continue statement is illegal in the
finally clause. (The reason is a problem with the current implementation --
this restriction may be lifted in the future).""" which is what applies to
the examples cited above.
Bob Gailer
bgailer@alum.rpi.edu
303 442 2625
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.537 / Virus Database: 332 - Release Date: 11/6/2003
- Next message: Tim Churches: "Re: Re: Rekall and associated software go 100% GPL"
- Previous message: David M. Wilson: "Re: raw string from mmap.read() possible?"
- In reply to: Alan Kennedy: "Re: try...finally is more powerful than I thought."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|