I have a folder like this
/test_mod
__init__.py
A.py
test1.py
/sub_mod
__init__.py
B.py
test2.py
And I want to use relatives imports in test1 and test2 like this
#test1.py
from . import A
from .sub_mod import B
...
#test2.py
from .. import A
from . import B
...
While I develop test1 or test2 I want that those imports to work while I am in the IDLE, that is if I press F5 while working in test2 that every work fine, because I don't want to do python -m test_mod.sub_mod.test2 for instance.
I already check this python-relative-imports-for-the-billionth-time
Looking at that, I tried this:
if __name__ == "__main__" and not __package__:
__package__ = "test_mod.sub_mod"
from .. import A
from . import B
But that didn't work, it gave this error:
SystemError: Parent module 'test_mod.sub_mod' not loaded, cannot perform relative import