Skip to main content

pdbg.py

Table of Contents

Introduction

pdbg is a debugging tool for python. It is designed to be a simple and lightweight tool for troubleshooting errors in Python code.

When run, this tool will run the specified script, while outputting all the variable definitions during the run. This is useful for when you want to watch the changes made to variables during the execution of your code and you don't have an IDE with a debugger. This is also useful even when you do have a debugger, as many debuggers don't allow you to go back to previous steps in your code, making it easy to forget what the previous values were. This tool will show you all the changes at once in the command line output or in a file, meaning that forgetting what happened will never be an issue.

All of the functionality of this module is provided through a single function. The options for this function are detailed in the Options section of this document

Installation

You can install pdbg with pip

pip install pdbg-bcit

Usage

Using this tool is very simple. In Windows, open CMD in the folder that you would normally run your python script. Then, enter the below command, with $filepath as the absolute path of the python script you want to debug.

python -c "import pdbg; pdbg.pdbg(r'$filepath')"

This method will run the script and output all the variable definitions and changes in the targeted file. More options for this method are detailed in options.

Example

Lets say we have a file with the following code.

def foo():
    bar = 0
    for i in range(3):
        bar += 1
    print(bar)

foo()

If we wanted to watch the variables changed in foo(), all we would have to do is open command line and run this command, with $filepath as the path of the python file.

python -c "import pdbg; pdbg.pdbg(r'$filepath', ['foo'])"

And this would be our output:

[Function] Entering function foo
[Debug]     bar = 0                                                  bar { None => 0 }
[Debug]     for i in range(3):                                       i { None => 0 }
[Debug]         bar += 1                                             bar { 0 => 1 }
[Debug]     for i in range(3):                                       i { 0 => 1 }
[Debug]         bar += 1                                             bar { 1 => 2 }
[Debug]     for i in range(3):                                       i { 1 => 2 }
[Debug]         bar += 1                                             bar { 2 => 3 }
3

Options

pdbg.pdbg(file, func_filter=[], var_filter=[], output_file=None, seperator=", ",output_format="{var_name} {{ {pre_value} => {new_value} }}")

  • [Required] file
    • Path to your Python script.
  • func_filter
    • Filter the output by function name.
  • var_filter
    • Filter the output by variables name.
  • output_file
    • Defaults to None. Redirect the output of pdbg to a file if specified. Will output by printing in console otherwise
  • separator
    • Separator used when multiple variables are changed in one line.
  • output_format
    • A string that formats the output
    • {var_name} will be the name of the variable,
    • {pre-value} will be the initial variable
    • {new_value} will be the variable after changes.
  • Read the Python doc for more about formatting.

Metadata

Release files for pdbg-bcit 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdbg-bcit 1.0.2
File Size Uploaded
pdbg-bcit-1.0.2.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdbg-bcit 1.0.2
File Interpreter ABI Platform
pdbg_bcit-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / pdbg-bcit-1.0.2.tar.gz

Download URL pdbg-bcit-1.0.2.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e187f4fdadf016ad4d365554faef5721f809c4deeabeee0fa4793efcd5358dc6
BLAKE2b-256 checksum
How to use checksums
5067362e11155b682f0654c6f649d1a7fca56ea36364988bb67d6b65fc0afb1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / pdbg_bcit-1.0.2-py3-none-any.whl

Download URL pdbg_bcit-1.0.2-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c885103dbfa3025b104615391b0b50aa457d4f0ecbc90d8426fd2fca9b29de8
BLAKE2b-256 checksum
How to use checksums
a3b9fb48b6d0658f0b99a319cab4b5cebffb3b020ddc6b929c1b2d5d4ca8a3e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page