Say I have some script, with a function my_function
. Now, this function needs several packages. So, let's say the file looks like this:
import package_A
import package_B
def my_function():
do_something
Now, if I want to use this function somewhere else, I may say
from my_file import my_function
my_function()
However, at this point, the call will halt with the error that package_A and package_B are not known.
How do I solve this? Do I have to make all the imports I do for my_function
again in the script calling my_function
? And if so, is there a way to automatically check and import all the imports in that file?