Visitar URL original
GitHub - samuelcolvin/python-devtools: Dev tools for python
The Wayback Machine - https://web.archive.org/web/20230819235734/https://github.com/samuelcolvin/python-devtools
Skip to content

samuelcolvin/python-devtools

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
August 17, 2023 15:49
August 17, 2023 15:49
August 17, 2023 12:18
August 17, 2023 12:18
September 3, 2021 18:52
November 25, 2022 11:37
August 17, 2023 15:49
April 5, 2023 12:45
April 6, 2023 00:45
August 17, 2023 12:18
September 9, 2017 17:26

python devtools

CI Coverage pypi versions license

Python's missing debug print command and other development tools.

For more information, see documentation.

Install

Just

pip install devtools

If you've got python 3.7+ and pip installed, you're good to go.

Usage

from devtools import debug

whatever = [1, 2, 3]
debug(whatever)

Outputs:

test.py:4 <module>:
    whatever: [1, 2, 3] (list)

That's only the tip of the iceberg, for example:

import numpy as np

data = {
    'foo': np.array(range(20)),
    'bar': {'apple', 'banana', 'carrot', 'grapefruit'},
    'spam': [{'a': i, 'b': (i for i in range(3))} for i in range(3)],
    'sentence': 'this is just a boring sentence.\n' * 4
}

debug(data)

outputs:

python-devtools demo

Usage without Import

devtools can be used without from devtools import debug if you add debug into __builtins__ in sitecustomize.py.

For instructions on adding debug to __builtins__, see the installation docs.