17
votes

I am using python to call a method in one class that is in one file from a method in another class of other file

Suppose my file is abc.py that contains

class data : 

         def values_to_insert(a,b):
               ......
                ......

another file is def.py

import abc
class values:
      data=abc.data()
      def sendvalues():
          a=2
          b=3
          data.values(a,b)

When I run this file it gives an error: values() takes exactly 2 arguments (3 given)

1
Probably because the 'self' parameter for Python methods is a very basic issue. - Martijn Pieters♦
ok. i thought the downvote was not justified considering the user is very new to this site. - rivu

1 Answers

24
votes

If it's in a class, your method should be :

def values_to_insert(self, a, b):

You can read about the reasoning for this here.