PyIntrospect is a lightweight Python introspection toolkit that provides structured, human-readable analysis of Python modules at runtime.
It builds on top of Python’s inspect module and organizes raw metadata into a consistent, categorized format for easier debugging, exploration, and tooling.
PyIntrospect extracts and structures module information including:
- Submodules
- Variables
- Constants
- Functions (with signatures and return types when available)
- Classes (with base classes and constructor signatures)
- Module source code (when accessible)
- Module file path
- Summary statistics
pip install pyintrospectimport pyintrospect
import os
r = pyintrospect.Reflect(os)
r.summary()Python provides powerful introspection tools such as dir() and inspect, but:
dir()is unstructured and noisyinspectis low-level and requires manual processing
PyIntrospect adds a semantic layer on top of inspect, producing structured and categorized output suitable for analysis and tooling.
| Parameter | Type | Description |
|---|---|---|
| module | Module | Target Python module |
| HideDunder | bool | Hide private and dunder members |
| pretty | bool | Print formatted output instead of returning raw data |
r.summary()Returns or prints:
- Module name
- File path
- Version (if available)
- Member counts by type
- Total members
r.submodules()Returns or prints submodules imported in the target module.
r.variables()Returns or prints module-level variables.
r.constants()Returns or prints module-level constants (uppercase identifiers).
r.functions()Returns or prints functions with:
- Name
- Signature
- Return type (if available)
r.classes()Returns or prints class definitions with:
- Class name
- Base classes
__init__signature
r.source()Returns or prints module source code (if available).
r.path()Returns or prints absolute file path of the module.
r.all()Returns or prints all available introspection data.
r.doc()
r.doc("function_name")Returns documentation for:
- Entire module (default)
- Specific attribute (function/class/variable if applicable)
pyintrospect <module> [options]pyintrospect os
pyintrospect os --functions
pyintrospect requests --classes --raw-a, --allShow all information (default if no filter is provided)-h, --helpShow help-V, --versionShow version
-f, --functionsShow functions-c, --classesShow classes-v, --variablesShow variables-C, --constantsShow constants-m, --submodulesShow submodules
-s, --sourceShow source code-p, --pathShow module path-d, --docShow documentation
-r, --rawDisable pretty print (return raw data)-D, --dunderInclude dunder/private members
- Built-in or compiled modules may not expose source code
- Some functions may not provide signature metadata
- Private members are filtered by default unless
HideDunder=False
PyIntrospect is designed with three principles:
- Structure over noise
- Readability over raw inspection
- Practical output over raw metadata
The goal is to make Python introspection usable in real tooling workflows, not just debugging sessions.
Current version: 0.2.2
MIT License
Copyright (c) 2026 Hoàng Long