I have a python class and within the class I call 2 different methods from one of the other methods. One works and one gives me a TypeError: get_doms() takes exactly 1 argument (2 given) :
def start(self,cursor):
recs = self.get_recs(cursor) # No errors here
doms = self.get_doms(cursor) # I get a TypeError here
def get_doms(self,cursor):
cursor.execute("select domain from domains")
doms = []
for i in cursor._rows:
doms.append(i[0])
return doms
def get_recs(self,cursor):
cursor.execute("select * from records")
recs = []
print cursor._rows
recs = [list(i) for i in cursor._rows]
return recs
How do I successfully call methods within my class from other methods within the same class? Why does one work and the other not?
~~thanks~~
I can’t reproduce the error you mention. I think the code is okay. But I suggest do not use
cursor._rowsbecause the_rowsattribute is a private attribute. Private attributes are an implementation detail — they are not guaranteed to be there in future versions ofcursor. You can achieve what you want without it, sincecursoritself is an iterator: