Is there a standard way to list names of Python modules in a package?
Even when `__all__` is not provided, `from x import *` is able to find all the modules in the given package.  Is there a straightforward way to simply list the names of those modules, without actually importing them?

The manual approach would be to iterate through the module search paths in order to find the package's directory.  One could then list all the files in that directory, filter out the uniquely-named py/pyc/pyo files, strip the extensions, and return that list.  But this seems like a fair amount of work for something the module import mechanism is already doing internally.  Is that functionality exposed anywhere?
Is there a standard way to list names of Python modules in a package?
===

Even when `__all__` is not provided, `from x import *` is able to find all the modules in the given package.  Is there a straightforward way to simply list the names of those modules, without actually importing them?

The manual approach would be to iterate through the module search paths in order to find the package's directory.  One could then list all the files in that directory, filter out the uniquely-named py/pyc/pyo files, strip the extensions, and return that list.  But this seems like a fair amount of work for something the module import mechanism is already doing internally.  Is that functionality exposed anywhere?