1import os
2with open(os.path.join(sys.path[0], "my_file.txt"), "r") as f:
3 print(f.read())
1# To call say_hello() from inside script.py, we can write in script.py:
2
3import mymodule
4
5mymodule.say_hello()
1# In a file system path, we would separate the components of a path
2# using / (Linux, macOS, etc.) or \ (Windows). In a Python import statement,
3# however, we separate the path components using a dot (.).
4
5import subdir.mymodule
6
7subdir.mymodule.say_hello()
1# Then if we're using Python 3.3 or higher, we can write in script.py:
2
3import subdir.mymodule
4
5subdir.mymodule.say_hello()