I have a simple project trying to illustrate how Python Path works.
Illustrated below is my current project structure.main.py
looks like this,
import pathlib
import sys
cwd = pathlib.Path(__file__).parent.resolve()
source_directory = cwd / 'depth_1' / 'depth_2' / 'depth_3'
sys.path.append(str(source_directory))
Each row_x_file.py
simply contains one function,
def row_x_print():
print("Inside row_x_file.py")
(With the x
substituted for the correct number). Each __init__.py
is simply from . import *
Now, because I have added the path to depth_3
to the sys.path
I can successfully type import row_1
without an error. However I can never access the function that is exported from the __init__
, i.e. I cannot run row_1_print()
after import row_1
, but import row_1
runs without failure. from row_1 import row_1_print
does not seem to succeed either.
How do I make it so after successfully typing import row_1
I can run the function inside of row_1_file.py
?