Skip to main content

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


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 hashes)

Uploaded Source

Built Distribution

constable-0.0.1-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page