Display my project
's directory structure:
tree project
project
├── config.py
├── __init__.py
└── project.py
Content in project.py:
from . import config
def main():
pass
if __name__ == '__main__':
main()
Content in __init__.py
:
__all__ = ['project','config']
from project import *
from . import config
config.py
is blank for simplicity.
To load the module:
cd project
import project
It encounter the error info: Parent module '' not loaded, cannot perform relative import
Why can't import project
?
I found that if project.py
renamed as myproject.py
, keep any other thing the same as before,import project
can work.
Does not the package project
share same name with module project.py
?
Why same names matter?