Adding a float to an integer using a method (not an operator) [duplicate]
问题 This question already has answers here : Difference between a+b and a.__add__(b) (1 answer) Python: __add__ and +, different behavior with float and integer (1 answer) Closed 16 days ago . I was expecting __add__ to work, but that's obviously not the case (in Python 3.8.0 at least): >>> 10 .__add__(5.5) NotImplemented >>> 10 .__radd__(5.5) NotImplemented The other way around works: >>> 5.5 .__add__(10) 15.5 >>> 5.5 .__radd__(10) 15.5 Why doesn't the first code work? Is there a good reason