Function() takes exactly 2 arguments (3 given)

Question:

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)

Asked By: vaibhav

||

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.

Answered By: Miklos Aubert
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.