M
Michele Simionato
I think I want "re-entrant exceptions" (not sure if this is the
correct name).
Consider the following example:
class NotSeriousException(Exception):
pass
def do_this():
raise NotSeriousException()
def do_that():
pass
def do_this_and_that():
do_this()
do_that()
Since the exception is raised at the do_this() level, do_that() will
not be executed. However, since the exception is not that serious, I
would like to catch it and continue from the point the exception was
raised, i.e. something like that:
try:
do_this_and_that()
except NotSeriousException:
continue # does not work of course
where "continue" would continue from do_that().
Is there some elegant or hackish way to get this?
Notice that I do NOT want to modify the source code of
do_this_and_that.
It comes from real life code and I could modify it, but if there was
some
smarter way of getting what I want I would be interested ...
Michele Simionato
correct name).
Consider the following example:
class NotSeriousException(Exception):
pass
def do_this():
raise NotSeriousException()
def do_that():
pass
def do_this_and_that():
do_this()
do_that()
Since the exception is raised at the do_this() level, do_that() will
not be executed. However, since the exception is not that serious, I
would like to catch it and continue from the point the exception was
raised, i.e. something like that:
try:
do_this_and_that()
except NotSeriousException:
continue # does not work of course
where "continue" would continue from do_that().
Is there some elegant or hackish way to get this?
Notice that I do NOT want to modify the source code of
do_this_and_that.
It comes from real life code and I could modify it, but if there was
some
smarter way of getting what I want I would be interested ...
Michele Simionato