Python Forum
TypeError: Method takes takes exactly 1 argument but 2 given
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: Method takes takes exactly 1 argument but 2 given
#1
Hi Below is my code:

import SimpleHTTPServer
import SocketServer
import os
from threading import Thread
import threading


class MyThread(Thread):
   def __init__(self,streampath):
       ''' Constructor. '''

       Thread.__init__(self)
       self.streampath = streampath

   def __str__(self):
       return str(self.streampath)
   def run(self):
       #self.streampath=str(streampath)
       os.chdir(self.streampath)
       PORT = 8000
       Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

       httpd = SocketServer.TCPServer(("", PORT), Handler)

       print "serving at port", PORT
       print "function thread", threading.currentThread()
       httpd.serve_forever()
       print "test1"


if __name__ == '__main__':

  obj1 = MyThread("C:\\\\QED")

  obj1.start()
  obj1.run("C:\\\\QED")
  print threading.currentThread()
  print('test2')
The above code implementing of creation of web server using multi threading. Please observe the code in MAIN function. My main intention is to call run() method by passing argument as path. When i do that it is showing following error.
Error:
TypeError: run() takes exactly 1 argument (2 given)
Could someone helpo me where i am going wrong. 

My Main intention is i need to call run(streampath) by passing argument from robot framework it is showing following above error.
Reply


Messages In This Thread
TypeError: Method takes takes exactly 1 argument but 2 given - by pras120687 - Dec-15-2016, 06:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: to_capabilities() missing 1 required positional argument: 'self' OceansBlue 2 5,325 Dec-03-2020, 12:08 AM
Last Post: OceansBlue
  TypeError: missing 1 required positional argument (word counter Django app) Drone4four 2 14,634 Jul-11-2019, 09:34 PM
Last Post: Drone4four
  TypeError("index() missing 1 required positional argument: 'pymydb'" nikos 2 4,293 Mar-03-2019, 09:21 PM
Last Post: micseydel
  TypeError: get_names() takes 0 positional arguments but 1 was given Truman 2 10,226 Aug-15-2018, 10:32 PM
Last Post: Truman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020