Search code examples
pythonargumentsipnmap

How to pass an ip address inside a thread argument as one argument?


I am writing a recon tool for scanning networks with threading using threading module, but the threads gives me a type error and tells me that every character in the thread arg section is a single argument

 for host in nm.all_host():
        threadx = threading.Thread(target=some_function, args=(host))
        thread_list.appened(threadx)
        thread.start()

TypeError: some_function() takes exactly 1 argument (11 given) 11 given refers to the gateway address which has 11 characters including "." 13 given refers to the client address which has 13 characters including "."


Solution

  • You are passing a string instead of a tuple, to pass a tuple you should add a comma after host like this:

    threadx = threading.Thread(target=some_function, args=(host,))