3 ms·
You can split your big module into modules inside a sub-package and import stuff in the __init__.py file from the submodules to present a nice interface to the
by plq 4y ago
You can split your big module into modules inside a sub-package and import stuff in the __init__.py file from the submodules to present a nice interface to the library user.
eg instead of:
namespace.py
class C1:
class C2:
do
namespace/__init__.py
from .c1 import C1
from .c2 import C2
namespace/c1.py
class C1:
namespace/c2.py
class C2:
- eloisius 4y agoThat’s what I described as the facade module approach.
- eesmith 4y agoWhat I don't like about this approach is how I'm supposed to refer to something by namespace.C1 but its repr is namespace.c1.C1. I would prefer if the repr reported its primary public API name, not its internal implementation location.