Rich-powered interactive touch REPL for introspection and debugging
Project description
touch
Rich-powered terminal “micro-debugger” for Python.
- Inspect values with pretty, readable output.
- Peek the source of functions/classes with highlighted snippets.
- Wrap functions so every call prints a compact, useful trace.
- Hot-edit functions in your editor and swap them in at runtime.
- Open a scratch file, write code, inject it straight into your scope.
All from a tiny toolkit that plays nicely with your console.
Install
pip install hyv-touch
Python 3.9+ recommended.
TL;DR
from touch import touch, embrace
# Wrap functions for pretty call/return/exception panels:
orig = embrace(globals()) # wraps everything in this scope
# Start an interactive loop over your current environment:
# Usually you want this at the point you want to inspect. Ex. at a `except` block.
touch(globals(), locals())
# If you used embrace() once touch is done
release(globals(), orig) # restore originals
# ------------- [ Inside the touch REPL ] ------------- #
# Pretty value inspection:
feel({"a": 1, "b": [2, 3, 4]})
feel(some_object) # Specially useful in objects, functions and Exceptions
# Show source snippet
source(some_function)
# Live-edit a function in VS Code
edit(some_function) # by default has `touch's` scope, or pass `scope=globals()`
# Open a temp file in VS Code, write new helpers, inject into scope:
retouch()
# If changes we're made to main file or it's dependencies, you can reload with:
# This will add any new symbols to the current scope, but will not overwrite existing ones.
tickle()
var_name # will show var_name's value
function() # will call function()
$exec a = (1, 2, 3) # run statements with $exec prefix or use retouch() for more complex actions
Why use this
You want quick, legible debugging without committing to a full debugger session. touch gives you:
- Readable output (Rich panels, tables, syntax highlighting)
- Low friction (one-liners, minimal API)
- Reversibility (wrappers can be released, edits are temporary)
- Hot-editing (Test and tweak without restarting or losing state)
- Versatility (All language and state available at all times)
Editor integration
- VS Code: requires the
codeCLI on PATH. In VS Code, run “Shell Command: Install ‘code’ command” from the Command Palette. - Other editors: set
$EDITORto your editor’s CLI.edit()andretouch()will use it when VS Code isn’t available.
Examples
run python -m touch.demo [--demo | --interactive] to see a demo script showcasing touch features.
Limits and notes
- Builtins and C-extensions don’t have Python source to show or edit.
- Editing nested closures can lose captured locals if you move them; keep edited functions top-level or use in-place file editing.
- The temporary trace hook used for line breakpoints is restored after each call and won’t clobber other tracers.
- Executing code you type or edit runs in your process. Don’t paste untrusted code.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hyv_touch-0.1.2.tar.gz.
File metadata
- Download URL: hyv_touch-0.1.2.tar.gz
- Upload date:
- Size: 42.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40d50e2e1ba480cc1c91c89b40d1f1da883c9b92fb3483d4352dad898a273fd6
|
|
| MD5 |
f2ea90f67e99b7e58f365137e698c253
|
|
| BLAKE2b-256 |
2a4bd211c3666c40ca6ddf69e21f4ae4e1a5baeeed626e217ee2354d316e5dcc
|
File details
Details for the file hyv_touch-0.1.2-py3-none-any.whl.
File metadata
- Download URL: hyv_touch-0.1.2-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8130b1a88e0c1a9ce7c6db15b436a0db1ec555ae6277b762981faef04b39c8a4
|
|
| MD5 |
f009d765ad5dfbfb48d6b6209a115580
|
|
| BLAKE2b-256 |
7f85cc76d976c6da9b8b7fd4595339112b254a1c4557a4d9673d3dd7af1ea27d
|