Skip to main content
https://img.shields.io/pypi/v/dvg-debug-functions https://img.shields.io/pypi/pyversions/dvg-debug-functions https://github.com/Dennis-van-Gils/python-dvg-debug-functions/actions/workflows/python-package.yml/badge.svg https://coveralls.io/repos/github/Dennis-van-Gils/python-dvg-debug-functions/badge.svg https://img.shields.io/badge/code%20style-black-000000.svg https://img.shields.io/badge/License-MIT-purple.svg

DvG_debug_functions

Provides functions for neatly printing debug information to the terminal output, well-suited for multithreaded programs.

Supports PyQt5, PyQt6, PySide2 and PySide6.

Installation:

pip install dvg-debug-functions

API

Functions

  • print_fancy_traceback(err=None, back: int = 3, show_full_paths: bool = False)

    Print the exception or the current regular call-stack traceback to the terminal, using ANSI color codes that mimic the IPython command shell.

    Args:
    err (Exception | str | None, optional):

    When err is of type Exception, then an exception traceback will be printed. When err is of another type, then the current regular call-stack traceback will be printed.

    Default: None

    back (int, optional):

    Depth of the traceback to print.

    Default: 3

    show_full_paths (bool, optional):

    Shows the full filepath in the traceback when True, otherwise just the filename.

    Default: False

    Example output:

    images/print_fancy_traceback.png
  • dprint(str_msg: str, ANSI_color: str = None)

    ‘Debug’ print a single line to the terminal with optional ANSI color codes. There is a lot of overhead using this print statement, but it is particularly well-suited for multithreaded PyQt programs where multiple threads are each printing information to the same terminal. The dprint() function ensure that each line sent to the terminal will remain as a continious single line, whereas a regular print() statement will likely result in the lines getting mixed up.

    The line will be terminated with a newline character and the terminal output buffer is forced to flush before and after every print. In addition, if PyQt5 is present in the Python environment, then a mutex lock will be obtained and released again for each dprint() execution.

  • tprint(str_msg: str, ANSI_color: str = None)

    Identical to dprint(), but now prepended with a time.perf_counter() timestamp.

Classes

class ANSI:
    NONE    = ""
    RED     = "\033[1;31m"
    GREEN   = "\033[1;32m"
    YELLOW  = "\033[1;33m"
    BLUE    = "\033[1;34m"
    PURPLE  = "\033[1;35m"  # aka MAGENTA
    MAGENTA = "\033[1;35m"
    CYAN    = "\033[1;36m"
    WHITE   = "\033[1;37m"

Changelog

2.5.0 (2024-06-22)

  • Using qtpy library instead of my own Qt5/6 mechanism

  • Using f-strings

  • Resolved pylint and pylance warnings

2.4.0 (2023-02-27)

  • Neater support for PyQt5, PyQt6, PySide2 and PySide6

  • Migrated from travis to Github actions

2.2.0 (2022-09-13)

  • Added support for PyQt5, PyQt6, PySide2 and PySide6

2.1.1 (2020-07-18)

  • Added flag show_full_paths to print_fancy_traceback()

2.1.0 (2020-07-17)

  • Improved print_fancy_traceback()

2.0.0 (2020-07-02)

  • DvG module filenames changed to lowercase

1.1.2 (2020-06-08)

  • Code style: black

1.1.1 (2020-06-06)

  • Extended README

1.1.0 (2020-06-04)

  • Added tprint(…)

0.0.1 (2020-05-13)

  • First release on PyPI.

Metadata

Release files for dvg-debug-functions 2.5.0

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

Source distribution (sdist)

Source distribution for dvg-debug-functions 2.5.0
File Size Uploaded
dvg-debug-functions-2.5.0.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dvg-debug-functions 2.5.0
File Interpreter ABI Platform
dvg_debug_functions-2.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.7 kB

Release files / dvg-debug-functions-2.5.0.tar.gz

Download URL dvg-debug-functions-2.5.0.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
092f82b50a7ed66d2d974878fcd4dec3b9fd536e2564c1ba1d87acba2d0336be
BLAKE2b-256 checksum
How to use checksums
c6ede0ff24cdc8eaa5d4962573a46af44882c0684f2d9ea93a8521e7d335b6f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release files / dvg_debug_functions-2.5.0-py3-none-any.whl

Download URL dvg_debug_functions-2.5.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b31be0b8ff8a4c46d67f928e0b525c74e2ccc98efc1264f0b9fdf55cc0e3d8f6
BLAKE2b-256 checksum
How to use checksums
f1d07719af0ef8840d2eb9babcb7b7e04343a126b81e056e6925ea78cf5a0d88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

2.5.0 This release

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

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