I\'ve just published a PyPi package but after I pip install
-ed it myself, I found out that there are many visible modules that shouldn\'t be!
Actually, I ju
In general, there isn't a way to "hide" a given variable/function/class/module in Python. Everything is available for importing to the user, even things in the standard library.
In practice, it is idiomatic in Python to prefix something that is not part of a public API with an underscore, such as:
from gutenberg_cleaner import _internal_helper_method
This indicates to your users who are aware of this idiom that "this is not meant to be imported".
This doesn't actually prevent the user from importing this internal function, but for most projects, this is sufficient (and I think this is what you should do here).
That said, there is another option: there is a third-party library publication that does precisely what you want: you define a list of functions that can be imported, and the library prevents the rest from being imported. It's not widely used, but it does resolve your question.