title: Python - Overloading of a method (with operator oveloading) for varying # arguments?
body: <p>As a newbie to object oriented, I'm practicing class using this:</p>
  
  <pre><code>import numpy as np    
  
  class complex():
  
      def __init__(self, arg1, arg2 = None):
          self.real = arg1
          if arg2 == None:
              self.imag = 0
          else:
              self.imag = arg2            
          self.num = np.complex(self.real, self.imag)               
  
      def __mul__(self, other):
          if np.iscomplex(other):
              return np.multiply(self.numb, other.num)
          else:
              return np.multiply(self.num, other)
  
      def __str__(self): 
          return "Foo"
  
  def test():        
      a = complex(3)
      b = complex(1, 5)        
      print(a * b)
  
  if __name__ == "__main__":
      test()
  </code></pre>
  
  <p>I'm trying to overload the operator <code>*</code> simultaneously oveloading the class method <code>__mul__</code> since I got different permutations of arguments passing in. The above code can do <code>(object, object)</code> or <code>(object, 'int')</code>. </p>
  
  <p><strong>How to pass <code>self</code> as the second argument something like <code>('int', object)</code>?</strong></p>
  
  <p>Things I tried from my basic understanding: <em>(correct me if I'm wrong)</em></p>
  
  <ol>
  <li>Static method with <code>self</code> as second argument, but inbuilt operators cannot be overloaded in a static method.</li>
  <li>Overloading the method <code>__mul__</code>, but not sure on a good-pratice/right-way to force <code>self</code> as second argument.</li>
  </ol>
  
  <p>Appreciate any help in advance. Please comment below if you need more info.</p>