Though I am new to Python I've inherited some existing code that has existing functions that I'd like to be able to wrap with a try structure.
# The following type of code works but isn't in the desired format...
try:
old.function ( another_function_call() == True )
except
my.cleanup()
The format that is desired is as follows:
my.function ( another_Function_call() == True )
But the problem is that if the Function_call() throws an exception, the point at which the occurs is prior to the try. Even if the original test is wrapped e.g.
my.function ( self, expression )
try:
old.function ( expression )
except:
my.cleanup()
It appears that the function that is passed into the my.function as a part of the expression has the expression called/executed prior to the actual calling of my function code and thus the try is never reached. Is there a way around this one without having to re-write the original code or adding a try structure around the whole call?
Thanks for any guidance!
# The following type of code works but isn't in the desired format...
try:
old.function ( another_function_call() == True )
except
my.cleanup()
The format that is desired is as follows:
my.function ( another_Function_call() == True )
But the problem is that if the Function_call() throws an exception, the point at which the occurs is prior to the try. Even if the original test is wrapped e.g.
my.function ( self, expression )
try:
old.function ( expression )
except:
my.cleanup()
It appears that the function that is passed into the my.function as a part of the expression has the expression called/executed prior to the actual calling of my function code and thus the try is never reached. Is there a way around this one without having to re-write the original code or adding a try structure around the whole call?
Thanks for any guidance!