I'm implementing a Fraction class to work with fractions (although python have a library for this), well the problem is, I can use the __add__ (+) operator between a fraction and an integer, but I can't use __add__ between an integer and a fraction. When the expression's order changes, I get an error.
>>> a = Fraction(1, 2)
>>> a + 1
Fraction(numerator=3.0, denominator=2)
>>> 1 + a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'Fraction'
>>>
Is there a way to make this expression 1 + Fraction(1, 2) work? Perhaps a left __add__ operator for the Fraction class?
__radd__