Here is what my directory tree looks like:
one/
config.py
two/
__init__.py
A.py
B.py
When I import functions or classes from A
and B
inside the __init__.py
, it has to be like this:
from .A import func
from .B import cls
However, importing names from config.py
can go straight like this:
from config import something
From what I know, since the .
indicates the "current directory", why doesn't from A import func
also work? On the other hand, config.py
sits on the parent directory of __init__.py
, how is from config import something
supposed to work? Shouldn't that be from ..config import something
instead? I'm a little confused.