Absolute imports are recommended, as they are usually more readable and tend to be better behaved (or at least give better error messages) if the import system is incorrectly configured (such as when a directory inside a package ends up on sys.path):
from . import elections, strategies, methods
Though there are a lot of other packages that do it this way.
I've always been confused about the best way to do this stuff.
Currently the overall package structure is what I want:
As is the methods sub-package:
But the other two include cruft that shouldn't be exposed to the user, such as
np
andcdist
, andelections
includes itself:Also the
__init__.py
files have relative imports, despite this being mildly recommended against by PEP8:Though there are a lot of other packages that do it this way.
I've always been confused about the best way to do this stuff.