It is very important and useful to have all the dependencies in the .py file that will be listed in the import statements. Thus, we can easily track the source of all used modules.
Tell me, if you use module1.method somewhere and want to check where this method came from, you will always find it in the import statements at the top. This is why from module1 import * very discouraged.
We can do what you need carefully.
In your header.py file
import module1 import module2
In other files
import header header.module1.method()
If you think this makes your code more tedious due to longer function names, you can try this.
import header as h h.module1.method()
But please make sure your python files have no traceable modules.
source share