← Quiz: Context Managers: all 10 questions
Quiz: Context Managers · Question 5 of 10
What happens if exit returns True after an exception in the block?
What happens if __exit__ returns True after an exception in the block?
- A.The exception is raised twice
- B.The program stops
- C.The exception is suppressed and the program continues after the with block
- D.exit is called again
Answer & explanation
Correct answer: The exception is suppressed and the program continues after the with block
A true return value tells Python the exception has been handled.
Can you get the rest right without peeking?
Take the timed Quiz: Context Managers quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →