title: How to call a function from another class in python
body: <pre><code>class A:
    def add_f(self,a,b):
      return a+b
  
  class B:
    def sum_f(self,a,b,c):
      return A.add_f(a,b) + c
  
  B1= B()    
  print B1.sum_f(1,2,3)
  
  
  Traceback (most recent call last):
  File "C:/Users/wxu/Documents/test.py", line 10, in &lt;module&gt;
  print B1.sum_f(1,2,3)
  File "C:/Users/wxu/Documents/test.py", line 7, in sum_f
  return A.add_f(a,b) + c
  TypeError: unbound method add_f() must be called with A instance as first argument (got int instance instead)
  </code></pre>
  
  <p>When I don't have the self for sum_f(self,a,b,c), it gave me this error:</p>
  
  <pre><code>Traceback (most recent call last):
  File "C:/Users/wxu/Documents/test.py", line 10, in &lt;module&gt;
  print test1.sum_f(1,2,3)
  TypeError: sum_f() takes exactly 3 arguments (4 given)
  </code></pre>
  
  <p>Why is that?
  And how to call function add_f from class A in class B? Thank you for your help.</p>