Skip to main content

Smart code explainer for Python

Project description

PyPI

WhiffPy 🐍💨

WhiffPy is a smart Python code explainer and error analyzer designed for beginners, educators, and anyone who wants to understand Python code more deeply. It analyzes code, explains its structure in plain English, and provides actionable, friendly error messages.


🚀 Features

  • Beginner-friendly explanations of code structure using Python's AST
  • Human-readable error analysis with suggestions for common mistakes
  • Safe code execution with output and error capture
  • Flexible CLI: analyze files or code snippets, output as text or JSON, save results
  • Easy to extend: add new error hints or code patterns

📦 Installation

Using pip (recommended for general usage)

WhiffPy v0.1.2 is available on PyPI. You can install it directly with:

pip install whiffpy

After installation, run the CLI commands:

whiffpy path/to/file.py

Using Poetry (for development)

Ensure you have Python 3.9+ and Poetry installed.

# Clone the repository and install dependencies
git clone https://github.com/ParmeetBhamrah/whiffpy.git
git clone https://github.com/ParmeetBhamrah/whiffpy.git
cd whiffpy
poetry install

🛠️ Usage

Command Line Interface

Analyze a Python file:

whiffpy path/to/file.py

Analyze a code snippet directly:

whiffpy --code "print(1+1)"

Explain code structure only (no execution):

whiffpy path/to/file.py --explain-only

Output as JSON:

whiffpy path/to/file.py --json

Save output to a file:

whiffpy path/to/file.py --save result.txt

Python API

from whiffpy import analyze

code = "x = 1 / 0"
report = analyze(code)
print(report)

📁 Examples

Check the examples/ directory for demos:

  • examples/demo.py → Basic code execution and error capture
  • examples/demo_analyze.py → Full analysis with explanations

🧩 Development Notes

  • Add error hints → edit whiffpy/utils.py
  • Extend code explanations → edit whiffpy/explainer.py

📂 Project Structure

whiffpy/
│── __init__.py        # Main API (analyze)
│── cli.py             # Command-line interface
│── runner.py          # Code execution
│── explainer.py       # AST-based code explanations
│── error_analyzer.py  # Traceback parsing and suggestions
│── utils.py           # Error hints and result formatting
examples/              # Usage examples
README.md
pyproject.toml
poetry.lock
LICENSE

📄 License

WhiffPy is released under the MIT License.

Project details


Download files

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

Source Distribution

whiffpy-0.1.3.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

whiffpy-0.1.3-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file whiffpy-0.1.3.tar.gz.

File metadata

  • Download URL: whiffpy-0.1.3.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Windows/11

File hashes

Hashes for whiffpy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e40df4816d78ca5946227a9d52f9e758401df0339f082b75e9186d4a42d48cc9
MD5 1272f01a29a9df0ac76e4ceb98545a12
BLAKE2b-256 ad6c184ba9e5a59cda85b00760c671d7239f14dce12314b180a0fb2b50b702a8

See more details on using hashes here.

File details

Details for the file whiffpy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: whiffpy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Windows/11

File hashes

Hashes for whiffpy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9de235b30d3002d6631b3d8872dc73468dd492e7846e90410c25f9b21454cc0e
MD5 e36901eed5ffcd55aa2092145d4e5936
BLAKE2b-256 5f4f6b1b7bf33a250498c5aa8290b91a3d9c62f40ef1af7741fd0970d89ab61c

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