title: Calling a Variable from Another Function in Python
body: <p>I have spent the past few hours reading around but I'm not really understanding what I am sure is a very basic concept: passing values (as variables) between different functions.</p>
  
  <pre><code>class BinSearch:
      def __init__(self,length,leng,r,obj_function,middle):
          self.length = length
          self.leng = leng
          self.r = r
          self.obj_function = obj_function
          self.middle = middle
          self.objtobin(obj_function)
  
      def BinarySearch(length,leng,r):
          mid = np.arange(0,len(length),1)
          middle = min(mid) + (max(mid)-min(mid))//2
          L_size = []
          L = length[middle]
          L_size.append(L)
          return L
  
      def objtobin(self,obj_function):
          # length,leng,middle = BinSearch.BinarySearch()
          if (obj_function&gt;=0.98):
              return BinSearch.BinarySearch(self.length,min(leng),self.middle-1)
          else:
              return BinSearch.BinarySearch(self.length,self.middle+1,max(leng))
  BinSearch.objtobin(obj_function=max(objectivelist))
  </code></pre>
  
  <p>When I run the above code, BinSearch.objtobin code gives "objtobin() missing 1 required positional argument: 'self'" What should I do for this error?
  Thanks for help!</p>