Hi there,
Is it possible to have an 'except' case which passes control back to the
point after the exception occurred?
e.g.
# a function to open the file
# raises FileLockedExcep tion is file contains 'locked' information
def open_file(file_ name):
f = file(file_name, 'r')
{read first line for file lock info}
if first_line == "FILE LOCKED":
raise FileLockedExcep tion(lock_user, lock_timestamp)
{read remainder of file}
return True
# elsewhere in a user interface module
def open_command():
try:
open_file("foo. bar")
except FileLockExcepti on, X:
ans = tkMessageBox.as kyesno(title="F ile Locked", message="File
locked by '" + X.user + "' on " + X.time_stamp + "\nContinue
anyway?")
if ans == tkMessageBox.YE S:
# return control to the remainder of the open_file function.
How?
else:
return False
Any ideas?
Cheers,
Richard
Is it possible to have an 'except' case which passes control back to the
point after the exception occurred?
e.g.
# a function to open the file
# raises FileLockedExcep tion is file contains 'locked' information
def open_file(file_ name):
f = file(file_name, 'r')
{read first line for file lock info}
if first_line == "FILE LOCKED":
raise FileLockedExcep tion(lock_user, lock_timestamp)
{read remainder of file}
return True
# elsewhere in a user interface module
def open_command():
try:
open_file("foo. bar")
except FileLockExcepti on, X:
ans = tkMessageBox.as kyesno(title="F ile Locked", message="File
locked by '" + X.user + "' on " + X.time_stamp + "\nContinue
anyway?")
if ans == tkMessageBox.YE S:
# return control to the remainder of the open_file function.
How?
else:
return False
Any ideas?
Cheers,
Richard
Comment