How to open a thread whose target is in another file?
<p>I need to open a thread whose target is defined in a different file.</p>

<p>I would like to pass the target name through a string containing, of course, the name of the function I want to run on thread.
Is that impossible, or am I missing something? </p>

<p>For instance, here is my code:</p>

<p>Here is the code that has the target function:</p>

<pre><code># command.py

def hello():
    print("hello world")
</code></pre>

<p>and here is the code I will run:</p>

<pre><code># run.py

import threading
import commands

funcname = "hello"

thread1 = threading.Thread(target= ... , daemon=True)
thread1.start()
</code></pre>

<p>What do i need to put as target?</p>

<p>From the <a href="https://docs.python.org/3/library/threading.html#threading.Thread" rel="nofollow">python docs</a> the <code>target</code> has to be a callable object. From your example you should be able to just put </p>

<p><code>target=command.hello</code></p>

python multithreading