Skip to main content

Smart code explainer for Python

Project description

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
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.2.tar.gz (7.5 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.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whiffpy-0.1.2.tar.gz
  • Upload date:
  • Size: 7.5 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.2.tar.gz
Algorithm Hash digest
SHA256 ca7fd28fc57ca4395e042ba0d73e3d2681bb2696674515b5c70bcebc34e5de4e
MD5 877e9891010700f3dd0e46e60ff5ddff
BLAKE2b-256 6c6ed26481ea2ee464c626c5a011b030b5611167b9bea336a69c44792dcd5615

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whiffpy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 97e28bccde9e9f970c02c490c75be8029ca77218c78c487f078f449b10ab4686
MD5 04ddc8544b9f6da0f0423920cd8e4f29
BLAKE2b-256 3f9054ca68b88e7307af436ff69f792127b6816fb68b3a88dc1d1855f9fbab7e

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