Question:
I have the code block like below:todo()
first, then either return
or raise e
. Is it possible to just write todo()
once? I was thinking using finally
but don’t think that actually works.Answer:
You could catch both exceptions in oneexcept
clause, execute todo
and then decide to do based on the exception type:If you have better answer, please add a comment about this, thank you!