I'm having a hard time understanding how imports work in Python 3.x. Suppose I have a project structure like this
test
../foo
....foo1.py
....foo2.py
../bar
....bar1.py
My understanding is that foo
and bar
can be treated as packages and the .py
files as modules.
I want to import foo1
and bar1
in foo2
(which is the main script). How can that be done in both absolute and relative ways?
If I want to execute foo2
after this, is this a bad project structure (maybe foo2
should be placed elsewhere, but I do not want to place it at the root)?