I am writing a package and the folder structure is like:
/package_name
__init__.py
module_1.py
module_2.py
If in module_2 I want to import module_1, is it better to do
1)
import module_1
or
2)
import package_name.module_1
?
Both ways can run successfully. 1) makes more sense to me, because the code is shorter, and also avoids the unnecessary import of __init__.py
in approach 2). However when I do 1), the IDE gives an unresolved import
error, despite it can run without any problem. And if I do 2) the IDE doesn't give the error. So I am wondering if 2) is the more recommended approach.
I am using Python 3.6. My IDE is Eclipse + Pydev.
-- edit --
'import module' or 'from module import' is an entirely different question. I don't see how my question is a duplicate of that one.