pypyp
Easily run Python at the shell! Magical, but never mysterious.
What it is and what it does
pyp is a command-line tool that lets you run Python code directly from the shell without boilerplate. You write a Python expression or snippet, and pyp statically analyzes it to infer what you need: it detects undefined variables like `x` (current line), `lines` (all lines), `stdin`, or `i` (loop index), automatically imports any modules you reference, and executes the code with those bindings in place. The result is printed intelligently—dicts and iterables format nicely, and the last expression prints automatically unless it's None or you explicitly call print yourself.
It's designed to replace common shell utilities: `ls | pyp 'x[:3]'` acts like cut, `cat file | pyp 'sum(map(int, lines))'` acts like awk, and `cat data.json | pyp 'json.load(stdin)[0]'` acts like jq. You can also use `--explain` to see the generated Python script before running it, chain multiple pyp invocations, or configure a custom config file (via PYP_CONFIG_PATH) to predefine functions and imports for your own use cases.
Use it for:
- Extract or transform text line-by-line: `ls | pyp 'x.upper()'` or `cat file | pyp 'x.split()[2]'`
- Aggregate or filter input: `cat data | pyp 'sum(map(int, lines))'` or `cat words | pyp 'x if "python" in x else None'`
- Process structured data: `curl api | pyp 'json.load(stdin)[0]["key"]'` or `cat file.csv | pyp 'len(lines)'`
- Add line numbers or indices: `cat file | pyp 'f"{idx+1}: {x}"'`
- Understand generated code before execution: `pyp --explain 'complex_expression'` to inspect the AST transformation
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pyp lets you write Python expressions and scripts directly at the shell, automatically handling imports, magic variables for input lines, and intelligent output formatting without requiring explicit print statements.
Yes, if you regularly write one-liners at the shell and want to avoid boilerplate imports and explicit print statements. The low install friction, permissive license, and lack of known vulnerabilities make it safe to try. The aging maintenance status (595 days since last release) is a minor concern for a stable utility, but the active repository and solid user base suggest it remains reliable for its narrow, well-defined purpose.
Install
pypyp on PyPI
pip
pip install pypypuv
uv add pypyppoetry
poetry add pypypInstalling pypyp
Before you install
Low friction: pure Python wheel with a single runtime dependency (astunparse). Maintenance is aging—last release was 595 days ago—but the repository remains active and unarchived with a modest user base (1528 stars).
License in practice
MIT license (permissive) means you can use, modify, and redistribute pypyp with minimal restrictions, making it safe for both personal and commercial projects.
Quickstart
pip install pypyp
# In shell:
echo -e "hello\nworld" | pyp 'x.upper()'
# In Python (less common):
import subprocess
result = subprocess.run(['pyp', 'x.upper()'], input=b'hello\n', capture_output=True)
print(result.stdout.decode())
Requires Python 3.8 or above; pyp is primarily a shell command-line tool, not a library for direct Python import.
Verify before relying
- Whether the --explain output is guaranteed to be runnable Python or merely illustrative
- Performance characteristics when processing very large input streams
- Compatibility with all standard library modules beyond those explicitly mentioned
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — astunparse |
| Maintenance | aging — 595 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 108,435/month — #12,558 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pypyp-1.3.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
bashProvides a Python wrapper for running bash…
copyleft · top 15,000 on PyPI
setproctitleAllows a Python process to change its own title…
permissive · top 1,000 on PyPI
plumbumPlumbum lets you write shell-script-like…
permissive · top 5,000 on PyPI
piperPypiper manages shell command execution within…
permissive · top 15,000 on PyPI
subprocess.runProvides a simplified interface to run shell…
permissive · top 15,000 on PyPI
pipePipe enables shell-like infix syntax for…
permissive · top 15,000 on PyPI
subprocrunnerWraps Python's subprocess module to simplify…
permissive · top 15,000 on PyPI
ptyprocessRun a subprocess in a pseudo terminal (pty) and…
permissive · top 1,000 on PyPI
pprintpppprintpp is a drop-in replacement for Python's…
permissive · top 5,000 on PyPI
runsRuns multiple subprocess commands from a text…
permissive · top 5,000 on PyPI