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 Poetry (recommended for development)

Ensure you have Python 3.9+ and Poetry installed.

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

Using pip (for general usage)

If you’ve installed WhiffPy locally using pip, you can run commands directly:

pip install whiffpy
whiffpy path/to/file.py

🛠️ 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.0.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.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whiffpy-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 d5b935226bddfb0e0964c6e856c7decedbf737fdc496cfc8550e2f130ba09d74
MD5 ebef40b3deb16a2e04b9aa37aba36c0f
BLAKE2b-256 227600643cf172913c30ca4d712086e607a1cbaa2e186ea81948227bcfef8bc6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whiffpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94a9d8c39d39e236d6b246bfd930016af868a6213c3e899a50159e4b489c6b16
MD5 7e6cdb35f66024cfe59ae9f6c35cd60c
BLAKE2b-256 604c3b40050426fda4b8f131a10c21442f4f6f441544b9340482b7d2dcf6aea4

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