One decorator for lazy debugging. Inserts print statements directly into your AST.
Project description
constable
One decorator for lazy debugging. Inserts print statements directly into your AST.
View the Github repository and the official docs.
$ pip install constable
Tested for python 3.8 and above.
Key Features
Capture function args and result
Monitor variable state at each assignment op
Measure execution time
Any of the above can be turned on/off.
Usage :
Monitoring functions
import constable
@constable.trace()
def add(a=1, b=2):
return a + b
add(1, 2)
Output :
executing: add(a = 1, b = 2) execution time: add(a = 1, b = 2) -> 0.00014877 seconds
Tracing variable assignments
import constable
@constable.trace(['a', 'b'])
def do_something(a=5, b=6):
a = a + b
c = a
a = "Experimenting with the AST"
b = c + b
a = c + b
return a
do_something(1, 2)
Output :
executing: do_something(a = 1, b = 2) debug: do_something: a = 3 debug: do_something: a = Experimenting with the AST debug: do_something: b = 5 debug: do_something: a = 8 execution time: do_something(a = 1, b = 2) -> 0.00009584 seconds
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
constable-0.0.1.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file constable-0.0.1.tar.gz
.
File metadata
- Download URL: constable-0.0.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d93780d62dd4210b7d2daeafd0313927d64844042ca5168b5a56b1a021dfcf7 |
|
MD5 | 8030b99fb829216fc72e87fd54c7bad0 |
|
BLAKE2b-256 | c294fec7b298def31dc2e61815412feebde551e7094e9ddead6c837c59f9a864 |
Provenance
File details
Details for the file constable-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: constable-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4ed90cd3f8a244a38c6cbe50ae2e0e562cf80b36e5117a63657d4409b979c9f |
|
MD5 | 01010d5d8b812037775dc4f2e93fb83e |
|
BLAKE2b-256 | 766cf104f6c93e05196321bb988bdb5ae0793b4449f5cd1297551ef685aa028b |