• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1504
  • Last Modified:

TypeError: __init__() takes exactly 3 arguments (1 given)

THREADING !!! my main window should create the InsertData window.  Then,
pass that window object into my thread.  call PostEvent to
send an event to that object requesting your repopulating.
im getting many error but I don't understan what arguments it is expecting

TypeError: __init__() takes exactly 3 arguments (1 given)
File "c:\Python26\sign\OCTOBER 13_Server_pyevent.py", line 6799, in <module>
  ThreadClass().start()

Open in new window


class ThreadClass(threading.Thread):
    def __init__(self, parent, event):
        self.parent = parent
        self.event = event
        threading.Thread.__init__(self)
    
    def run(self):

        host = ''
	port = 51269
	backlog = 5
	size = 1000000
	addr = (socket.gethostname(), port)
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.bind((addr))
	s.listen(backlog)
	while 1:
	    client, addr= s.accept()    
	    data = client.recv(size)
	    if data:
		client.send(data)		
		sqlite_file_to_write = open("recieved_dataII.txt", "ab"  )
		sqlite_file_to_write.write(data)    
		sqlite_file_to_write.close()
		
	    client.close()
	    fname="recieved_dataII.txt"
	    f = open(fname, 'rb')    # notice the binary mode again
	    reader = csv.reader(f)
	    for row in reader:
		
		(Incident_number,Last_Name,First_Name,Age,Gender,Address,City,State,Zip,Ailment,Treatment,Patient_reprt,Initial_contact,Hospital, 
		Destination,Inservice,Provider_1,Provider_2,Sys,Dia,Pulse,Resp,Weather,Temp,Humid,Wind,TimeStamp,Refusal) =row
		
		Actual_Incident_number=None
		
		con = lite.connect('specialeventms2011a.sqlite')
		cur = con.cursor()
		cur.execute('insert into ptrecords values(?,?,?,?,?,?,?,?,?,?,?,?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0)',
		    (Actual_Incident_number,Incident_number, Last_Name, First_Name, Age,Gender,Address,City,State,Zip
		     ,Ailment,Treatment,Patient_reprt,Initial_contact,Hospital,Destination,Inservice,
		     Provider_1,Provider_2,Sys,Dia,Pulse,Resp,Weather, Temp,Humid,Wind,TimeStamp,Refusal))
		con.commit()
		cur.close()
		con.close()
		
	    f.close()
	    open('recieved_dataII.txt','w').close
	    wxPostEvent(self.prent,RepopulateEvent())
ThreadClass().start()

Open in new window

0
dolamitejenkins
Asked:
dolamitejenkins
1 Solution
 
peprCommented:
See your code:

class ThreadClass(threading.Thread):
    def __init__(self, parent, event):
        self.parent = parent
        ...

Open in new window


The __init__ has 3 arguments.  It is called automatically after the object is created.  The object is passed via the self -- this is the first argument.  The second two arguments are taken from parentheses when you "call" the ThreadClass.

The following ThreadClass().start() can be written as two statements:

    obj = ThreadClass()
    obj.start()

Open in new window


In other words, the .start() is called later and has no influence to the problem.  The problem is that you were expected to pass 2 arguments, like:

        obj = ThreadClass(arg1, arg2)

Open in new window

0
 
dolamitejenkinsAuthor Commented:
thank you
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now