The documentation for threading.Thread(target=...)
states that
target
is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
I usually use it like this:
import threading
def worker():
a = 3
print("bonjour {a}".format(a=a))
threading.Thread(target=worker).start()
Is there a way to chain the function elements in target
so that a new one does not need to be defined? Something like (pseudocode obviously)
threading.Thread(target=(a=3;print("bonjour {a}".format(a=a))).start()
I have a bunch of very short calls to make in the Thread
call and would like to avoid multiplication of function definitions.