Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function() takes exactly 2 arguments (3 given) [duplicate]

Tags:

python

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)

like image 749
vaibhav Avatar asked Jul 26 '13 06:07

vaibhav


1 Answers

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.

like image 184
Miklos Aubert Avatar answered Nov 07 '22 01:11

Miklos Aubert