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.1.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.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whiffpy-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 5f07e6de086dfd9e3433268a7eeec49a50ffaa9bcbe235034c9fffce1d5a1d5f
MD5 4de51aa98536cc3e7b066874ec038ca2
BLAKE2b-256 948b5a3bcbd316143730c6185e8a4335beaead95c49aeee9547681606ba3b2c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whiffpy-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 433dda3f378c69f39e2c54e79b7994a10274318047af85f384286e0a3a9cd6f9
MD5 35eae1b041d7068e1c147344b326dc1c
BLAKE2b-256 60d275be82c8e1c5a9949ab4ad09ac3693694d1cf1e869421735d3e4364ea97b

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