Question 11
Back to Exercise
Which method makes a + b work for objects of your class?
- A __add__ Correct
- B __plus__
- C __sum__
- D __concat__
Correct Answer: Option A
a + b calls a.__add__(b); if that returns NotImplemented, Python tries b.__radd__(a).
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!