Raising an exception in the caller's frame
Thomas Heller
theller at python.net
Thu Mar 20 15:14:22 EST 2003
Is there any way to raise an exception in the callers (parent) frame?
See the following code, I want the exception to be raised in the
do_some_work function, without changing this function itself:
def check_result(value):
if somecondition(value):
raise ValueError
return value
def do_some_work():
value = dosomething()
return check_result(value)
Thomas
More information about the Python-list
mailing list