How do you reraise an exception in Python?
Experience Level: Junior
Tags: Python
Answer
Use the try/except block and raise statement.
def do_reraise_exception():
try:
int('Not a number')
except ValueError:
print("A value error was intercepted")
raise
Related Python job interview questions
What does **kwargs mean in Python?
Python JuniorWhat does *args mean in Python?
Python JuniorWhy should you use private and protected methods instead of defining all methods as public in Python?
Python JuniorWhat is a static method in Python?
Python JuniorWhy should you convert your private class methods to static methods in Python whenever possible?
Python Junior