title: Python Class passing value to "self"
body: <p>I'm programming an optimizer that has to run through several possible variations. The team wants to implement multithreading to get through those variants faster. This means I've had to put all my functions inside a thread-class. My problem is with my call of the wrapper function</p>
  <pre><code>class variant_thread(threading.Thread):
      def __init__(self, name, variant, frequencies, fit_vals):
          threading.Thread.__init__(self)
          self.name = name
          self.elementCount = variant
          self.frequencies = frequencies
          self.fit_vals = fit_vals
      
      def run(self):
          print(&quot;Running Variant:&quot;, self.elementCount) # display thread currently running
          fitFunction = self.Wrapper_Function(self.elementCount)
      
          self.popt, pcov, self.infoRes = curve_fit_my(fitFunction, self.frequencies, self.fit_vals)
  
      def Optimize_Wrapper(self, frequencies, *params): # wrapper which returns values in manner which optimizer can work with
          cut = int(len(frequencies)/2) &lt;---- ERROR OCCURS HERE
          freq = frequencies[:cut]
          vals = (stuff happens here)
          return (stuff in proper form for optimizer)
  </code></pre>
  <p>I've cut out as much as I could to simplify the example, and I hope you can understand what's going on. Essentially, after the thread is created it calls the optimizer. The optimizer sends the list of frequencies and the parameters it wants to change to the Optimize_Wrapper function.</p>
  <p>The problem is that Optimize-Wrapper takes the frequencies-list and saves them to &quot;self&quot;. This means that the &quot;frequencies&quot; variable becomes a single float value, as opposed to the list of floats it should be. Of course this throws an errorswhen I try to take len(frequencies). Keep in mind I also need to use self later in the function, so I can't just create a static method.</p>
  <p>I've never had the problem that a class method saved any values to &quot;self&quot;. I know it has to be declared explicitly in Python, but anything I've ever passed to the class method always skips &quot;self&quot; and saves to my declared variables. What's going on here?</p>