{"id":1658,"library":"pypyp","title":"pypyp - Run Python at the Shell","description":"pypyp (Python at Your Prompt) is a command-line utility that allows users to easily execute Python code directly from their shell, often leveraging shell piping for data manipulation. It's designed to be a magical yet never mysterious tool for quick data processing and scripting, similar to `awk` or `sed` but with Python's full power. The current version is 1.3.0, and releases are generally made as features or fixes are needed.","status":"active","version":"1.3.0","language":"en","source_language":"en","source_url":"https://github.com/kellyjonbrazil/pypyp","tags":["cli","shell","utility","python","data-processing","automation"],"install":[{"cmd":"pip install pypyp","lang":"bash","label":"Install pypyp"}],"dependencies":[],"imports":[{"note":"pypyp is primarily a command-line tool. This import exposes the internal entry point for advanced usage, testing, or embedding, but it is not intended for typical programmatic use of pypyp's core functionality. Users should interact with pypyp via the `pypyp` shell command.","symbol":"cli_entrypoint","correct":"from pypyp.cli import cli_entrypoint"}],"quickstart":{"code":"echo \"hello world\" | pypyp 'x.upper()'","lang":"bash","description":"This quickstart demonstrates pypyp's core functionality: taking piped input and applying a Python expression to each line. The `x` variable holds the current line of input. The output will be 'HELLO WORLD'."},"warnings":[{"fix":"Always be mindful of which variable you are accessing. For line-by-line processing, `x` is the raw line. If you've split `x` (e.g., `x.split()`), then `_` will iterate over the parts. Refer to the official documentation for detailed examples.","message":"Understanding the input variables (`x`, `_`, `_i`) is crucial. `x` always refers to the raw input (a line when iterating, or the full input if not iterating). `_` refers to the currently iterated item (e.g., after `x.split()`). `_i` is the iteration index.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For simple expressions, double quotes are often sufficient. For more complex Python code, single quotes (`'...'`) are generally safer as they prevent shell expansion of variables within the Python string. If your Python code itself needs quotes, ensure they are distinct from the shell's outer quotes (e.g., `pypyp \"x.replace('old', 'new')\"`).","message":"Shell quoting can be tricky for Python expressions. Depending on the shell and the complexity of your Python code (e.g., involving dollar signs, backticks, or other shell special characters), you might need to experiment with single vs. double quotes, or escaping.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use pypyp for quick transformations, data filtering, and one-liners. For anything that requires significant logic, multiple functions, or larger codebases, write a standard Python script and execute it with `python your_script.py`.","message":"pypyp is designed for concise, single-expression or short-script execution. While it uses the full Python interpreter, it's not optimized for running large, multi-file Python applications. Performance and best practices for complex scripts should use standard `python` execution.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}