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.
- 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
WhiffPy v0.1.2 is available on PyPI. You can install it directly with:
pip install whiffpyAfter installation, run the CLI commands:
whiffpy path/to/file.pyEnsure 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 installAnalyze a Python file:
whiffpy path/to/file.pyAnalyze a code snippet directly:
whiffpy --code "print(1+1)"Explain code structure only (no execution):
whiffpy path/to/file.py --explain-onlyOutput as JSON:
whiffpy path/to/file.py --jsonSave output to a file:
whiffpy path/to/file.py --save result.txtfrom whiffpy import analyze
code = "x = 1 / 0"
report = analyze(code)
print(report)Check the examples/ directory for demos:
- examples/demo.py → Basic code execution and error capture
- examples/demo_analyze.py → Full analysis with explanations
- Add error hints → edit
whiffpy/utils.py - Extend code explanations → edit
whiffpy/explainer.py
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
WhiffPy is released under the MIT License.