If operations such as + are applied to two operands of different types, the corresponding method (in this case, __add__) of the left operand is invoked first. If this raises an exception, the reverse method (here, __radd__) of the right operand is called. If this method does not exist, a TypeError exception is raised.
In order to enable the operation , where is an instance of RationalNumber, we define __radd__ as:
class RationalNumber: .... def __radd__(self, other): return self + other
Note that __radd__ interchanges the order of the arguments; self is the object of type RationalNumber while other is the object that has to be converted.