I'm inside a python package where there is A.py, B.py and an init file that allows me to import packages into the directory above.
Thus, the content of my init file is as follows:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
I now want to import a class of B.py into A.py. I tried to use from B import myClass
but it doesn't work. I also tried to add the file in the path by adding this line to the init file :
__path__.append(__file__)
How to add B.py to the path ?
--edit--
To clarify things, here is the structure of my packages and modules :
|app.py
|package1
|__init__.py
|C.py
|package2
|__init__.py
|A.py
|B.py
In A.py I need to import classes from B.py and C.py
from .B import myClass
(note the.
)? – MisterMiyagifrom .B import myClass
andfrom ..C import myClass
? – MisterMiyagifrom .B import myClass
– Rig0L