I've noticed sometimes if you call dir()
on a package/module, you'll see other modules in the namespace that were imported as part of the implementation and aren't meant for you to use. For instance, if I install the fish package from PyPI and import it, I see fish.sys
, which just refers to the built-in sys
module.
My question is whether that's sane and what to do about it if it's not.
I don't think the __all__
variable is too relevant, since that only affects the behavior of from X import *
. The options I see are:
- structure your packages better, and at least push the namespace clutter down into submodules
- use
import X as _X
in your package to distinguish implementation details from your package API - import things from inside your functions (blegh)