Calling a function from a script, re-import all packages?
<p>Say I have some script, with a function <code>my_function</code>. Now, this function needs several packages. So, let's say the file looks like this:</p>

<pre><code>import package_A
import package_B

def my_function():
    do_something
</code></pre>

<p>Now, if I want to use this function somewhere else, I may say </p>

<pre><code>from my_file import my_function
my_function()
</code></pre>

<p>However, at this point, the call will halt with the error that package_A and package_B are not known. </p>

<p>How do I solve this? Do I have to make all the imports I do for <code>my_function</code> again in the script calling <code>my_function</code>? And if so, is there a way to automatically check and import all the imports in that file?</p>