You do not import scripts in Python, you import modules. Some python modules are also scripts that can be run directly (they do some useful work at the module level).
In general, it is preferable to use absolute imports rather than relative imports.
toplevel_package/ ├── __init__.py ├── moduleA.py └── subpackage ├── __init__.py └── moduleB.py
In moduleB :
from toplevel_package import moduleA
If you want to run moduleB.py as a script, make sure the parent directory for toplevel_package is in your sys.path .
jfs Jan 21 2018-12-12T00: 00Z
source share