ProgrammingHardIBM · Deloitte pattern

What is printed?

What is printed?
try:
    raise ValueError("x") from None
except ValueError as e:
    print(e.__cause__, e.__suppress_context__)
  1. A. None False
  2. B. x True
  3. C. None True
  4. D. ValueError True

Correct answer: C. None True

'from None' explicitly suppresses exception chaining: it sets __cause__ to None and __suppress_context__ to True, so Python won't show a chained traceback for this exception.

More Python Programming questions

Exams that ask this topic