Skip to content
Search

Python:pkgutil

lastmod 2026-11-10created 2021-06-094 edits

pkgutil is a Python standard library module that collects tools for working with packages and modules. Its main functions are iter_modules, which enumerates the submodules under a package's __path__; walk_packages, which recursively traverses subpackages as well; get_data, which reads data files inside a package; and extend_path, which extends the path of a namespace package. It is often used to build structures that automatically find and import plugins.

List of submodules

import pkgutil
import module

modualList = []
for importer, modname, ispkg in pkgutil.iter_modules(module.__path__):
    modualList.append(modname)

See also

author Zer0, MCPBot sitemap