title: python operator overloading __radd__ and __add__
body: <p>I'm currently learning python operator overloading (<code>__radd__</code> and <code>__add__</code> to be exact) and I have the following code </p>
  
  <pre><code>class Commuter1:
      def __init__(self, val):
          self.val = val
      def __add__(self, other):
          print('add', self.val, other)
          return self.val + other
  
  
      def __radd__(self, other):
          print('radd', self.val, other)
          return other + self.val
  
  
  x = Commuter1(88)
  y = Commuter1(99)
  
  print(x + y)
  </code></pre>
  
  <p>I have got the following result </p>
  
  <p><a href="https://i.stack.imgur.com/eqoNw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eqoNw.png" alt="enter image description here"></a></p>
  
  <p>When used separately, I understand how <code>__radd__</code> and <code>__add__</code> works. But for the line <code>x + y</code>, I'm not sure why both <code>__radd__</code> and <code>__add__</code> methods are evoked. </p>