A simple package to add code highlighting to the python debugger (PDB).
Project description
PDB Color
Add some color to the python debugger.
Installation
Install with pip.
pip install pdbcolor
Setup
Python can be configured to use PDB Color by changing the PYTHONBREAKPOINT
environment variable. To use PDB Color temporarily, add the
PYTHONBREAKPOINT=pdbcolor.set_trace prefix before running your python script:
PYTHONBREAKPOINT=pdbcolor.set_trace python3 main.py
To make PDB Color the default for all Python sessions, set the
PYTHONBREAKPOINT environment variable to pdbcolor.set_trace. On Mac and
Linux, you can do this with the export command:
export PYTHONBREAKPOINT=pdbcolor.set_trace
Add this line to your terminal configuration file (e.g. .bashrc or .zshrc)
to ensure the setting persists across terminal settings.
Usage
PDB Color is a drop-in replacement for PDB that simply adds color to PDB's outputs. See the PDB documentation for a PDB introduction.
PDB Color also has tab autocompletion by default which can be triggered using the TAB key. For example:
$ python3 main.py
> /home/alex/documents/pdbcolor/main.py(9)<module>()
-> y = 2
(Pdb) str.
str.capitalize( str.isalpha( str.ljust( str.rpartition(
str.casefold( str.isascii( str.lower( str.rsplit(
str.center( str.isdecimal( str.lstrip( str.rstrip(
str.count( str.isdigit( str.maketrans( str.split(
str.encode( str.isidentifier( str.mro() str.splitlines(
str.endswith( str.islower( str.partition( str.startswith(
str.expandtabs( str.isnumeric( str.removeprefix( str.strip(
str.find( str.isprintable( str.removesuffix( str.swapcase(
str.format( str.isspace( str.replace( str.title(
str.format_map( str.istitle( str.rfind( str.translate(
str.index( str.isupper( str.rindex( str.upper(
str.isalnum( str.join( str.rjust( str.zfill(
(Pdb) str.
Examples
Using PDB:
Using PDB Color:
Pytest
In pytest, using breakpoint() in your unit tests will put you into PDB by
default. To use PDB Color instead, set --pdbcls=pdbcolor:PdbColor. For
example:
python3 -m pytest --pdbcls=pdbcolor:PdbColor
To invoke PDB Color upon the failure of a test (post-mortem) rather than a
breakpoint, use the --pdb option:
python3 -m pytest --pdbcls=pdbcolor:PdbColor --pdb
If you get a pytest OS error such as:
OSError: pytest: reading from stdin while output is captured! Consider using `-s`.
And if you have changed your PYTHONBREAKPOINT environment variable to be
pdbcolor.set_trace, try changing the PYTHONBREAKPOINT variable back to
pdbcolor.set_trace. For example:
PYTHONBREAKPOINT=pdb.set_trace python3 -m pytest --pdbcls=pdbcolor:PdbColor
Pytest should use PDB Color as expected.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdbcolor-0.3.4.tar.gz.
File metadata
- Download URL: pdbcolor-0.3.4.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
687f35b261ee72af418246809be44575e5122f8569cadc19d2d9fff5fb1f27af
|
|
| MD5 |
d3d1d5f70015823a80cc528c845b46ce
|
|
| BLAKE2b-256 |
990891ce281426c68e31f3852140d82a52f76e74c4fb5b284b881d8f8c875e79
|
Provenance
The following attestation bundles were made for pdbcolor-0.3.4.tar.gz:
Publisher:
workflow.yml on Alex-JG3/pdbcolor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdbcolor-0.3.4.tar.gz -
Subject digest:
687f35b261ee72af418246809be44575e5122f8569cadc19d2d9fff5fb1f27af - Sigstore transparency entry: 196916839
- Sigstore integration time:
-
Permalink:
Alex-JG3/pdbcolor@626b5ffb1f262e956365e9605caaffd29fbd75a6 -
Branch / Tag:
refs/tags/0.3.4 - Owner: https://github.com/Alex-JG3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@626b5ffb1f262e956365e9605caaffd29fbd75a6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pdbcolor-0.3.4-py3-none-any.whl.
File metadata
- Download URL: pdbcolor-0.3.4-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d3aa8fa1ac3682327ec34bea3d7abc33c09be306b26f1ddcd5e4e5c9b42aa2e
|
|
| MD5 |
9ad812338a6dd92761691712ee114bd8
|
|
| BLAKE2b-256 |
d845d49c6e551170314c36c21d54efc3aface37a3221dc2fcae39d5ec10f2693
|
Provenance
The following attestation bundles were made for pdbcolor-0.3.4-py3-none-any.whl:
Publisher:
workflow.yml on Alex-JG3/pdbcolor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdbcolor-0.3.4-py3-none-any.whl -
Subject digest:
4d3aa8fa1ac3682327ec34bea3d7abc33c09be306b26f1ddcd5e4e5c9b42aa2e - Sigstore transparency entry: 196916849
- Sigstore integration time:
-
Permalink:
Alex-JG3/pdbcolor@626b5ffb1f262e956365e9605caaffd29fbd75a6 -
Branch / Tag:
refs/tags/0.3.4 - Owner: https://github.com/Alex-JG3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@626b5ffb1f262e956365e9605caaffd29fbd75a6 -
Trigger Event:
push
-
Statement type: