Language and Compiler Modules

pyclbr

Reads source-level class and function descriptions for browsing Python modules without executing their bodies. It is not a complete runtime introspection tool: dynamically created objects and changes made during import may not appear. Use inspect for live objects.

Formal Syntax & Structure

python syntaxpython
import pyclbr

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import pyclbrfrom tempfile import TemporaryDirectoryfrom pathlib import Pathwith TemporaryDirectory() as d:    (Path(d) / "bm_v42_demo.py").write_text("class Item:\n    pass\n")    info = pyclbr.readmodule_ex("bm_v42_demo", [d])    print(info["Item"].name)
Python Reference