January 27th, 2013, 10:28 AM
i have time class and two objects o1 and o2
with __radd__ funtion to overload +
when i call o1+o2, i expect o2.min to get incremented rather than o1 which is not the case
what i understand is that __radd__ is called when the object is on the right side of the operator, which in this case is o2
can anyone clear my doubt ?
January 27th, 2013, 10:58 AM
__radd__ will never be called when two objects of the same type are added, and when the objects are different types it is only called when the add method of the object on the left returns NotImplemented. (Ditto the other "reflected" operations.)