varInspect
Print a table of your Python variables — name, datatype, and value — straight from the running program.
from varinspect import listVars
def check_order(symbol, qty, price):
filled = False
tags = ["intraday", "nifty"]
risk = {"stop": 0.5, "target": 1.2}
listVars()
check_order("NIFTY26OCT25000CE", 50, 123.45)
name type value
===========================================
filled bool False
price float 123.45
qty int 50
risk dict {'stop': 0.5, 'target': 1.2}
symbol str 'NIFTY26OCT25000CE'
tags list ['intraday', 'nifty']
Install
pip install varInspect
The distribution is named varInspect; the importable module is lowercase
varinspect (PEP 8):
from varinspect import listVars, formatVars, VarRow
API
listVars(target=..., *, scope="locals", ...)
Prints the table and returns the printed rows as a list of VarRow.
| Parameter | Default | Meaning |
|---|---|---|
target |
caller's frame | What to inspect: omit for the caller's own variables, or pass a module, a mapping, or any object. |
scope |
"locals" |
"locals", "globals" or "both" — only used when target is omitted. |
include_private |
True |
Include names starting with a single underscore. |
include_dunder |
False |
Include __dunder__ names. |
sort_by |
"name" |
"name", "type" or "value". |
max_value_len |
60 |
Truncate each value to this many columns (0 = unlimited). |
max_width |
100 |
Cap the total table width; the value column absorbs the overflow (0 = unlimited). |
style |
"simple" |
"simple" (ASCII) or "box" (Unicode box drawing). |
file |
sys.stdout |
Where to print. |
formatVars(...)
Same signature, but returns the table as a string instead of printing it.
VarRow(name, type, value)
A frozen dataclass for one inspected variable. It unpacks like a tuple:
for name, type_, value in listVars():
...
More examples
Inspect a module or an object instead of the local scope:
import json
from varinspect import listVars
listVars(json) # everything bound in the json module
listVars(my_config_obj) # instance attributes plus class attributes
listVars({"a": 1}) # any mapping
Tune the output:
listVars(style="box", max_width=60)
listVars(scope="both", include_dunder=True, sort_by="type")
listVars(max_value_len=0, max_width=0) # never truncate
┌───────────────────────┐
│ name │ type │ value │
├───────────────────────┤
│ label │ str │ '完了' │
│ ok │ bool │ True │
└───────────────────────┘
Wide (CJK) characters are measured by display width, so columns stay aligned.
Notes
listVarsskips itself, sofrom varinspect import listVarsnever shows up as a variable of its own.__name__,__doc__and friends are hidden unless you ask for them.- A value whose
__repr__raises is reported instead of crashing the table. - Only the standard library is required.
Development
python -m pytest
python -m build
twine check dist/*
License
MIT
Metadata
Release files for varInspect 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| varinspect-0.1.0.tar.gz | 8.9 kB | Without provenance | Details for varinspect-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| varinspect-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for varinspect-0.1.0-py3-none-any.whl |
Total release size: 17.4 kB
Release files / varinspect-0.1.0.tar.gz
| Download URL | varinspect-0.1.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bca10deff0ba47247cc96e14de696f6eb1dc5e99bff2475217f05e686cb128c8
|
|
BLAKE2b-256 checksum How to use checksums |
cdbf631f87ab0b55df74882665bf7743d947d2a8573d1588f84b38d937af0675
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / varinspect-0.1.0-py3-none-any.whl
| Download URL | varinspect-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a22b4042b4ae599f852a31438df4d7bf8b3209121b24ca901e0da0633ab2edd2
|
|
BLAKE2b-256 checksum How to use checksums |
fdcc0abf57fe91d9e32bcc0bafb68e3088223937611897a8a17da50e72536d0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for varInspect 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.