I have the following code:
def my_function:
#operation 1
#operation 2
...
#operation 99
#operation 100
def handle_exception:
#handle exception
Now, during any part of executing my_function an exception might occur. If it does, I want to handle it by calling handle_exception method. And then go back to my_function and retry the same operation that caused the exception. If it works this time, continue with the code. The exceptions might happen in random places in the code and I don't want to retry whole my_function.
So for example. I am executing my_function. Operation 1 worked correctly. During operation 2 there was an exception. I handle the exception and then try operation 2 again. It works this time so I continue with operations.
Is this possible in Python?