On this page
pkgutil.iter_modules
Prev: pkgutil.iter_importers | Up: pkgutil | Next: pkgutil.ModuleInfo
Rel: pkgutil.extend_path, pkgutil.get_data, pkgutil.get_importer, pkgutil.iter_importers
Ref: docs.python.org — pkgutil.iter_modules
Tags: #public #python3 #stdlib #pkgutil
Import
import pkgutil
from pkgutil import iter_modules
Signature & Overview
pkgutil.iter_modules(path=None, prefix='')
Yields ModuleInfo for all submodules on path, or, if path is None, all top-level modules on sys.path.
Usage
import email
import pkgutil
names = [m.name for m in pkgutil.iter_modules(email.__path__)]
assert "policy" in names and "message" in names
Gotchas
- Does NOT import the discovered modules: Safe for plugin discovery before deciding what to import.
REPL Inspect
from pkgutil import iter_modules
help(iter_modules)
Linked from
Related notes
- tuts/python3/stdlib_module/pkgutil/extend_path Linked here; links to this page; shared tags: #pkgutil, #stdlib
- tuts/python3/stdlib_module/pkgutil/get_data Linked here; links to this page; shared tags: #pkgutil, #stdlib
- tuts/python3/stdlib_module/pkgutil/get_importer Linked here; links to this page; shared tags: #pkgutil, #stdlib
- tuts/python3/stdlib_module/pkgutil/iter_importers Linked here; links to this page; shared tags: #pkgutil, #stdlib
- tuts/python3/stdlib_module/pkgutil/ModuleInfo Linked here; links to this page; shared tags: #pkgutil, #stdlib
- tuts/python3/stdlib_module/pkgutil Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/pkgutil/read_code shared tags: #pkgutil, #stdlib
- tuts/python3/stdlib_module/pkgutil/walk_packages shared tags: #pkgutil, #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib