I'm changing a bunch of old python code that is occasionally running into name collisions between packages. I have a question about when absolute imports should be used and whether it would be proper to import same-level modules by name only.
/package/
/package/__init__.py
/package/subA
/package/subA/__init__.py
/package/subA/moduleA.py
/package/subA/moduleB.py
/package/subB
/package/subB/__init__.py
/package/subB/moduleA.py
/package/subB/moduleB.py
Should every import statement within the package look like:
import package.subX.moduleX
or
from package.subX import moduleX
What about in the subpackage __init__.py
files. Would it be wrong to simply put
import moduleA
import moduleB
Or, in /package/subA/moduleA.py, would it be wrong to simply put:
import moduleB