Question 13
Back to Exercise
What should __add__ return when it does not support the other operand's type?
- A None
- B False
- C raise NotImplementedError
- D NotImplemented Correct
Correct Answer: Option D
NotImplemented lets Python try the reflected method and, if that fails too, raise a proper TypeError.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!