Skip to main content

Provides following utilities for debugging Python applications:

  • show - lightweight function that prints name and value of your variable(s) to the console.

  • peep - featured, interactive interface for data inspection.

https://user-images.githubusercontent.com/11185582/51219128-b3127780-192f-11e9-8618-ecfff642b87f.gif

Installation

Install peepshow package:

pip install peepshow

PeepShow uses clear, vim, man commands which are available in most of Linux distributions. Users of other operating systems need to install them on their own.

Built-Ins

If you expect to use peepshow often, consider adding peep and show commands to Python’s built-ins. Edit either {site-packages}/sitecustomize.py or {user-site-packages}/usercustomize.py and append the following:

import peepshow
import builtins
builtins.peep = peepshow.peep
builtins.show = peepshow.show
builtins.peep_ = peepshow.peep_
builtins.show_ = peepshow.show_

Alternatively let the installer do it for you:

pip install peepshow --upgrade --force-reinstall --no-deps --install-option="--add-builtins"

Note that pip uninstall peepshow command will not undo this change. You need to do it manually.

Breakpoint

It is also possible to invoke peep() as a result of calling built-in function breakpoint(). To enable such behaviour use PYTHONBREAKPOINT system variable:

export PYTHONBREAKPOINT=peepshow.peep

Compatibility

  • This software is expected to work with Python 3.6, 3.7 and compatible.

  • It has never been tested under operating systems other than Linux.

  • It works fine when started in a plain Python script, in ipython or ptipython

  • In these environments like interactive python console, in pdb and ipdb, peep and show cannot infer names of the variables in the user context, so they need to be provided explicitely (e.g. use peep_` and show_).

Usage

show

Running this script:

x = 123
y = {'name': 'John', 'age': 123}
z = "Hello World!"

# show all the variables in the scope
show()

# or only variables of your choice
show(x, y)

# you can also rename them
show(my_var=x)

# use 'show_' to specify variable names as a string
show_('x')

# expressions and renaming are also allowed
show_('x + 321', zet='z')

will result in following output:

x = 123
y = {'age': 123, 'name': 'John'}
z = 'Hello World!'
x = 123
y = {'age': 123, 'name': 'John'}
my_var = 123
x = 123
x + 321 = 444
zet = 'Hello World!'

peep

Try to run the following script:

x = 123
y = {'name': 'John', 'age': 123}
z = "Hello World!"

# inspect dictionary that consists of all the variables in the scope
peep()

# or inspect variable of your choice directly
peep(x)

# use 'peep_' to specify variable name as a string
peep_('x')

When interactive interface pops up:

  • hit ENTER to see list of available variables

  • type 10 and hit ENTER to select y

  • hit ENTER again to see items of your dictionary

  • type dir and hit ENTER to list attributes of y (excluding built-ins)

  • type continue and hit ENTER to proceed or type quit and hit ENTER to terminate your script

Note that all the commands have their short aliases. E.g. quit and q is the same.

For more help:

  • type help and hit ENTER to see list of available commands

  • type man and hit ENTER to read the manual, hit q when you are done

Development

Preparing Environment

./setup.sh
source venv/bin/activate

Modifying Dependencies

# edit setup.py
# edit requirements*.in
pip-compile
pip-sync
# git add... commit... push...

Testing

pytest

Releasing

# update version in setup.py
python setup.py sdist
twine upload dist/peepshow-$VERSION.tar.gz
git tag $VERSION
git push --tags

Release files for peepshow 0.1.5

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

Source distribution (sdist)

Source distribution for peepshow 0.1.5
File Size Uploaded
peepshow-0.1.5.tar.gz 22.5 kB Details

Release files / peepshow-0.1.5.tar.gz

Download URL peepshow-0.1.5.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
31fbca686baa6bd1c42eb79d8ea58cb9e182a2b4e17cdd0d6ab1a0cb41f8e1d4
BLAKE2b-256 checksum
How to use checksums
c68ac4021b586db07950856d70490668547474af4caa1e07f1021bffde3a34ac
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/28.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.2

Release history Release notifications | RSS feed

0.3.0

2 release files

0.2.3

2 release files

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.6

1 release file

This release

0.1.5 This release

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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