I'm new to Python, and given the following directory structure, I would like to import a function (let's call it function2) from script2 to script1, such that it works on a call in python script1.py
and python script.py
.
For example: script1 -> calls script2
; script -> calls script1 -> calls script2
What would the best way to do that?
I'm getting a lot of confusion about relative/absolute path, and I've seen in some cases __init__.py
inside each "package".
root
┣ modules
┃ ┣ package1
┃ ┃ ┗ script1.py
┃ ┗ package2
┃ ┗ script2.py
┗ script.py