close
The Wayback Machine - https://web.archive.org/web/20191115203721/https://github.com/samuelcolvin/python-devtools
Skip to content
Python Makefile
Branch: master
Clone or download
Image Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Image devtools
Image docs
Image tests
Image .gitignore
Image .pyup.yml
Image .travis.yml
Image HISTORY.rst
Image LICENSE
Image Makefile
Image README.rst
Image demo.py.png
Image dev-requirements.txt
Image setup.cfg
Image setup.py

README.rst

python devtools

BuildStatus Coverage pypi

Dev tools for python.

The debug print command python never had (and other things).

For more information, see documentation

Install

Just:

pip install devtools[pygments]

(pygments is not required but if it's available output will be highlighted and easier to read.)

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:

https://raw.githubusercontent.com/samuelcolvin/python-devtools/master/demo.py.png

Usage without Import

modify /usr/lib/python3.6/sitecustomize.py making debug available in any python 3.6 code

# add devtools debug to builtins
try:
    from devtools import debug
except ImportError:
    pass
else:
    __builtins__['debug'] = debug
You can’t perform that action at this time.