Skip to main content

Debug print statements, done right. E.g. show(x)

Project description

PyPI Package latest release PyPI Package monthly downloads Supported versions Supported implementations Wheel packaging support Test line coverage
from show import *

x = 12
nums = list(range(4))

show(x, nums)

yields:

x: 12  nums: [0, 1, 2, 3]

Output is self-labeled, so you don’t spend time doing that yourself.

Debug Printing

Logging, assertions, unit tests, and interactive debuggers are all great tools. But sometimes you just need to print values as a program runs to see what’s going on. Every language has features to print text, but they’re rarely customized for printing debugging information. show is. It provides a simple, DRY mechanism to “show what’s going on.”

Sometimes programs print so that users can see things, and sometimes they print so that developers can. show() is for developers, helping rapidly print the current state of variables in ways that easily identify what value is being printed, without a lot of wasted effort. It replaces the craptastic repetitiveness of:

print "x: {0!r}".format(x)

with:

show(x)

And Much More

While avoiding a few extra characters of typing and a little extra program complexity is nice (very nice, actually), show does much more. As just a taste, show.changed() displays local values that have changed since it was last run:

def f():
    x = 4
    show.changed()
    x += 1
    retval = x * 3
    show.changed()
    return retval

When run will display:

x: 4
x: 5  retval: 15

Decorate a function with @show.inout and it will show you the input parameters as the function is called, and then the return value later.:

@show.inout
def g(a):
    b = 3
    a += b
    show.changed()
    return a

g()

Displays:

g(a=4)
a: 7  b: 3
g(a=4) -> 7

And of course show does normal output too, just like say (with all of its high-level text formatting):

wizard = "Gandalf"
show("You have no power here, {wizard}!")

Prints:

You have no power here, Gandalf!

Just like you knew it would.

Long story short, show is working toward being a full-featured debugging companion that prints the maximum amount of useful information with the minimum amount of fuss.

For this and much more, see the full documentation at Read the Docs.

New and Notable

A new capability is to differentially set the formatting parameters on a method by method basis. For example, if you want to see separators in green and function call/return annotations in red:

show.sep.set(style='green')
show.inout.set(style='red')

You could long do this on a call-by-call basis, but being able to set the defaults just for specific methods allows you to get more formatting in with fewer characters typed. This capability is available on a limited basis: primarily for format-specific calls (blanklines, hr, sep, and title) and for one core inspection call (the inout decorator). It will be extended, and mapped back to underlying say and options features over time.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

show-1.2.5.zip (49.2 kB view details)

Uploaded Source

show-1.2.5.tar.gz (35.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

show-1.2.5-py2.py3-none-any.whl (21.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file show-1.2.5.zip.

File metadata

  • Download URL: show-1.2.5.zip
  • Upload date:
  • Size: 49.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for show-1.2.5.zip
Algorithm Hash digest
SHA256 6d62445d5064c9b24f6edef2a8eadff42d7ca0ec55f11c67907254fba7a5c6e2
MD5 9f7b440db089e4191edb31342791e329
BLAKE2b-256 34f52211cbd3e6a7edc00470a72980b17a2ec025b90d49adf4ce6cc70028a097

See more details on using hashes here.

File details

Details for the file show-1.2.5.tar.gz.

File metadata

  • Download URL: show-1.2.5.tar.gz
  • Upload date:
  • Size: 35.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for show-1.2.5.tar.gz
Algorithm Hash digest
SHA256 e7fd8164d9a0580e4eaab48fade9beba9630720541660818a08f98b2e2302bc7
MD5 dfd895ef07b45a06adaa4286d7015613
BLAKE2b-256 cb3e6610e3999840921a0af40965267d837528f74b190cf77bd97187ba78690f

See more details on using hashes here.

File details

Details for the file show-1.2.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for show-1.2.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4b8a6696755e3613a56aab6f749928dc0a00372132869e2db9220a3ef95ee689
MD5 697e5e37a17bce75be8ff6f267170162
BLAKE2b-256 c586ddd782a3fdc70493e531be0b9febee504366c6bbd0b47f7e0f27eacb1443

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page