title: Python Question. TypeError: __call__() takes 2 positional arguments but 3 were given
body: <p>I am glad for any help anyone can provide! I am working on a code for a basic Fourier Analysis program, and to calculate the set of coefficients I realized out of efficiency's sake I wanted to multiply functions so it can provide a single function that can be numerically integrated. I got some help and now have an 'operable' class which should help me do this. Here is the code for the 'operable' class, above the code for my program:</p>
  
  <pre><code>
  class operable:
      def __init__(self, f):
          self.f = f
      def __call__(self, x):
          return self.f(x)
  
  def op_to_function_op(op):
      def function_op(self, operand):
          def f(x):
              return op(self(x), operand(x))
          return operable(f)
      return function_op
  
  for name, op in [(name, getattr(operator, name)) for name in dir(operator) if "__" in name]:
      try:
          op(1,2)
      except TypeError:
          pass
      else:
          setattr(operable, name, op_to_function_op(op)) 
  
  </code></pre>
  
  <p>Now I am calling a function which is operable, from this function call here on the 6th line.</p>
  
  <pre><code>def findFourierCoefficients(function, T, kmax):
      coefficientsA = [] #will have size kmax
      coefficientsB = []
      for i in range(0, kmax):
          #find the coefficient a_k
          integrandA = integrandForAK(function, i) #HERE IS THE FUNCTION CALL
          integrationA = simpson(integrandA, 0, T, nValue)
          coefficientA = (2/T) * integrationA
          coefficientsA.append(coefficientA) 
      return coefficientsA
  </code></pre>
  
  <p>I've looked online and found that I need to provide a third parameter to my function, and I have done this below with the parameter 'self'.</p>
  
  <pre><code>@operable
  def integrandForAK(self, fun, k):
      def specialCosineFunction(x):
          return np.cos(k * omega * x)
      functionToIntegrate = fun * specialCosineFunction
      #functionToIntegrate = getFunctionProduct(fun, specialCosineFunction)
      return functionToIntegrate
  </code></pre>
  
  <p>I am still getting this error, that it only takes two positional arguments when three were given - but I have made another argument in my function so I don't know why it doesn't recognize it. Thank you again for any help anyone can provide, I am fairly new to this level of coding - python in particular is newer to me. All the best!</p>