title: User defined __mul__ method is not commutative
body: <p>I wrote a class to represent vectors in Python (as an exercise) and I'm having problems with extending the built-in operators.</p>
  
  <p>I defined a <code>__mul__</code> method for the vector class.  The problem is that in the expression <code>x * y</code> the interpreter calls the <code>__mul__</code> method of x, not y.</p>
  
  <p>So <code>vector(1, 2, 3) * 2</code> returns a vector &lt;2, 4, 6> just like it should; but <code>2 * vector(1, 2, 3)</code> creates a TypeError because the built-in int class does not support multiplication by my user-defined vectors.</p>
  
  <p>I could solve this problem by simply writing a new multiplication function</p>
  
  <pre><code>def multiply(a, b):
      try:
          return a * b
      except TypeError:
          return b * a
  </code></pre>
  
  <p>but this would require redefining every function that I want to use with my user-defined classes.</p>
  
  <p>Is there a way to make the built-in function handle this correctly?</p>