Skip to main content

During talks or screencasts I don’t want to be typing code, it is too error prone and too likely to mess up my speaking flow. Purdy is both a set of programs and a library to display colourized code in a series of animations.

The purdy command displays your program or data to screen with colourization. It supports a number of syntax highlighters including Python, Python REPL, Bash console and more. Source code can be presented to the screen as if typing. For console files, the typing pauses at a prompt, waiting for interaction. Prompts are:

  • >>> or ... for Python REPL

  • $ for Bash console

If the program is paused at a prompt, pressing the right arrow will continue. Typing animation can be skipped over by pressing the letter “s” instead. Animation can be undone by pressing the left arrow. More info on keys can be found in the help dialog, viewed by pressing “h”.

Example Usage:

$ purdy code-snippet.py

The result looks like this:

screenshot.gif

Once the code has been displayed, further key presses are ignored. At any time you can press “q” to quit.

Purdy Programs

The following programs come with the purdy library:

  • purdy – Animated display that looks like a program is being typed to the screen.

  • subpurdy – Full set of commands to control Purdy. Sub-commands dictate behaviour, doing a variety of code presentation. Includes ANSI, RTF, HTML output as well as the typewriter animations.

More information can be found in the Command Line Program Documentation.

Purdy TUI Controls

The following keys help you to control the TUI purdy programs:

  • h – Help screen

  • <RIGHT> – next animation step

  • <LEFT> – previous animation step

  • s – go to the next step, skipping any animation

For custom made code using the purdy library, the following controls will also work:

  • <TAB> – focus next window area in a multi Screen display

  • <SHIFT><TAB> – focus previous window area in a multi Screen display

Additionally the s, and <LEFT> commands all support skipping multiple steps by specifying a number first. For example the sequence 12s would skip past the next 12 steps.

Purdy Library

The purdy script is fairly simple, but you can create more complex animations by writing programs using the purdy library. Custom programs can have split screens, highlight lines, do slide transitions, and more. More information can be found in the Library Documentation.

Installation

$ pip install purdy

Supports

Purdy has been tested with Python 3.13. Terminal control is done with the Textual library. Parsing and tokenization is done through Pygments. Both libraries are excellent and I’m grateful they’re publicly available.

Purdy was re-written from the ground up for version 2, moving to Textual and doing an API redesign based on pain points over the years. Version 2 is not compatible with version 1 which was based on Urwid. For the deprecated version see the purdy 1 branch or pip install purdy==1.14.1.

Docs & Source

Docs: http://purdy.readthedocs.io/en/latest/

Source: https://github.com/cltrudeau/purdy

Metadata

Release files for purdy 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 purdy 2.5.0
File Size Uploaded
purdy-2.5.0.tar.gz 55.1 kB Details

Built distribution (wheel)

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

Total release size: 107.0 kB

Release files / purdy-2.5.0.tar.gz

Download URL purdy-2.5.0.tar.gz
Size 55.1 kB
Tags Source
SHA-256 checksum
How to use checksums
19999226dcac23b2b8b227b527bd577d5fe8647497066abf44dc3a80ee589917
BLAKE2b-256 checksum
How to use checksums
aa66c5324ca176a7059ee3d0af8e871a31e6ebeb751a5f92adf62593f6813084
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0rc2

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

Download URL purdy-2.5.0-py3-none-any.whl
Size 51.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
337683969e7df6f1e7a4f1bc89b25f8fec033f868337e38c99c16dc2cd9ff1b4
BLAKE2b-256 checksum
How to use checksums
a8bb88d90d1bfb763aa29631ad8511af6255c72a2f90e4cfe0fa60f8c4965bcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0rc2

Release history Release notifications | RSS feed

This release

2.5.0 This release

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.14.1

2 release files

1.13.2

2 release files

1.13.1

2 release files

1.13.0

2 release files

1.12.0

2 release files

1.11.0

2 release files

1.10.1

2 release files

1.10.0

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.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