Python pkgutil Module
Example
List top-level modules available on the import path:
import pkgutil
for x in pkgutil.iter_modules():
print(x.name)
Try it Yourself »
Definition and Usage
The pkgutil module provides helpers for working with packages and the import system.
Use it to discover modules, walk packages, fetch data files, and tweak package search paths.
Members
Member | Description |
---|---|
extend_path() | Extend a package's __path__ so it can span multiple directories. |
get_data() | Read a binary resource from a package. |
get_importer() | Return the finder/loader responsible for a given path entry. |
get_loader() | Return the loader for the named module or package. |
iter_modules() | Iterate over modules on the import path or inside a package. |
ModuleInfo | Named tuple describing a discovered module (finder, name, ispkg). |
resolve_name() | Resolve a dotted name string to a Python object. |
walk_packages() | Yield modules recursively found under package paths. |