Re: Resume after exception
- From: Dan Sommers <me@xxxxxxxxxxx>
- Date: 14 Jun 2005 07:59:31 -0400
On Tue, 14 Jun 2005 10:09:30 +0100,
"Richard Lewis" <richardlewis@xxxxxxxxxxxxxx> wrote:
> Hi there,
> Is it possible to have an 'except' case which passes control back to the
> point after the exception occurred?
Not that I can think of.
[ example of "interrupting" a file-reading function in order to ask the
user if they really want to read a locked file ]
I would rewrite that this way (untested, and without error checking):
def open_file(file_name, read_if_locked=False):
f = file(file_name)
[read first line]
if first_line == "FILE LOCKED" and read_if_locked == FALSE:
return False
[read the rest]
return True
def open_command():
if open_file("foo.bar") == False:
[ask the user what to do]
if ans == tkMessageBox.YES:
open_file("foo.bar", True )
Regards,
Dan
--
Dan Sommers
<http://www.tombstonezero.net/dan/>
.
- References:
- Resume after exception
- From: Richard Lewis
- Resume after exception
- Prev by Date: Re: windows directory
- Next by Date: Re: Reg cgi header
- Previous by thread: Resume after exception
- Next by thread: Re: Resume after exception
- Index(es):
Relevant Pages
|