threading args to many arguments given error?

Viewed 39

I am trying to threading to call a function with args, but the Syntax I use says I am using to many args... but 2 are needed to are given... so why?

import threading
import time

class Baab():

    def finc(phrase):
        time.sleep(3)
        print(phrase)

    def fenc():
        time.sleep("last")

    def fanc(ophrase):
        print(ophrase)


def func(phrase, ophrase):
    b = Baab()
    b.fanc(ophrase)
    b.finc(phrase)
    b.fenc()

th = threading.Thread(target=func, args=("baba", "lol"))
th.start()
time.sleep(1)
print("second")   
1 Answers

The class methods expect a self attribute explicitly.

Try changing your class method as below:

class Baab():

    def finc(self, phrase):
        time.sleep(3)
        print(phrase)

    def fenc(self):
        time.sleep("last")

    def fanc(self, ophrase):
        print(ophrase)
Related