1

I have a class that is called in a couple of contexts:

class Datamodel:
    def __init__(self, habvalues, hablist=[], orglist=[], genlist=[]):
        self.habvalues = habvalues
        self.uses_database = False
        if hablist and orglist and genlist:
            self.hablist = hablist
            self.orglist = orglist
            self.genlist = genlist
            self.uses_database = True

There is one method that calls this class using only the habvalues parameter, and it seems to work fine. However, when called using all the parameters, with lists that are shown by my logging calls to contain valid data, I get the following error message:

__ init__() takes 7 positional arguments but 8 were given

The calling function reads like this:

self.newmodel = evocontrol.Datamodel(self.habvalues, self.habRecords, self.orgRecords, self.genlist)

So, the error message seems to be wrong. There are not 7 positional arguments in my code, only 4. And only 4 are given.

What could be the source of a miscount such as this? What kinds of things should I be looking for here?

bastelflp
  • 9,362
  • 7
  • 32
  • 67

1 Answers1

0

Please, try passing the arguments as keyword arguments

self.newmodel = evocontrol.Datamodel(self.habvalues, hablist=self.habRecords, orglist=self.orgRecords, genlist=self.genlist)
J.M. Robles
  • 614
  • 5
  • 9