From the description of the import statement in the language reference [1]:
The *public names* defined by a module are determined by checking the module's namespace for a variable named ``__all__``; if defined, it must be a sequence of strings which are names defined or imported by that module. The names given in ``__all__`` are all considered public and are required to exist. If ``__all__`` is not defined, the set of public names includes all names found in the module's namespace which do not begin with an underscore character (``'_'``). ``__all__`` should contain the entire public API. It is intended to avoid accidentally exporting items that are not part of the API (such as library modules which were imported and used within the module).
As an example of names which should be excluded from the public API the
reference mentions names of modules which were imported and used within
the module. And they are perhaps the most common cases. It is often
imported module names are the only non-underscored names which are
imported by a star-import by accident.
For example, modules re and sys were used in Lib/idlelib/editor.py but
there were no imports for them. This worked because they were imported
implicitly by `from tkinter import *`. [1]
There is other case when a module name can be occurred in the module
namespace: if it is a submodule. For example:
>>> from xml.etree import *
>>> ElementTree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ElementTree' is not defined
>>> ElementPath
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ElementPath' is not defined
>>> import xml.etree.ElementTree
>>> from xml.etree import *
>>> ElementTree