pyDefine
Convert Python errors into beginner-friendly explanations and guides you with actionable solutions ✨
pyDefine is a pure-Python developer library created by Yahya Mundewadi (Portfolio: yahya.in). pyDefine takes raw Python tracebacks and exceptions and converts them into clean, beginner-friendly explanations with actionable fix suggestions and source code context previews. Perfect for students, educators, and developers!
- 🌐 Official Website: pydefine.yahya.in
- 👨💻 Author Portfolio: yahya.in
- 📦 PyPI Package: pypi.org/project/pydefine
Features 🌟
- 164+ Exception Types Covered - Comprehensive support for built-ins, Web APIs, Databases, Data Science (Pandas/NumPy), Asyncio, Security, and Validation errors.
- 16 Core Categories - Structured categorization from Syntax, Types, and Math to Database, Network, and Concurrency.
- Source Code Context Previews - Automatically reads target source lines and highlights the exact error line with a pointer (
>). - Dynamic Class Inheritance Fallback - Custom and third-party library exceptions automatically inherit explanations from their base exception classes.
- Actionable Fix Suggestions - Every error comes with an immediate, plain-English solution.
- Multiple Interfaces - Use as a library (
import pydefine), CLI tool (pydefine script.py), or interactive decoder. - Pure Python & Zero Dependencies - Fast, lightweight, and works anywhere Python runs.
- Safe Code Execution - Built-in
safe_run()for testing code snippets with live error decoding. - Production Ready - 100% test pass rate, type-hinted, and Ruff-linted.
Installation 📦
From PyPI (Recommended)
pip install --upgrade pydefine
From Source
git clone https://github.com/mdyahhya/pydefine.git
cd pydefine
pip install -e .
Quick Start 🚀
1. Global Exception Hook (Easiest)
Just enable pyDefine once at the start of your script or app:
import pydefine
pydefine.enable()
# Normal code - any uncaught exception will now show a clean card!
number = 10
divisor = 0
result = number / divisor
Output:
┌─ ➗ Error: ZeroDivisionError ──────────────────────────────────────────
│ Category : Arithmetic & Math
│ Message : division by zero
│ Location : app.py:6
│
│ Summary : Division or modulo operation by zero was attempted.
│ Fix : Check if the divisor is zero before performing division.
│
│ Context :
│ 5 │ divisor = 0
│ > 6 │ result = number / divisor
└───────────────────────────────────────────────────────────── pyDefine ─
2. Manual Decoding in try/except
import pydefine
try:
data = {"name": "Alice"}
print(data["email"])
except Exception as e:
pydefine.quick_decode(e)
3. Quick One-Liner Explanation
import pydefine
try:
int("hello")
except Exception as e:
print(pydefine.explain(e))
# 🎯 ValueError: An argument received the correct data type but an invalid value.
Command Line Interface (CLI) 💻
Run scripts directly through pydefine with live diagnostic reports:
# Run a Python script with error diagnostics
pydefine script.py
# List all 16 categories
pydefine --list
# Filter exceptions by category
pydefine --category "Database & SQL"
pydefine --category "Web & HTTP APIs"
# List all 164+ exceptions
pydefine --list-all
Supported Categories 📂
- Syntax & Formatting (
SyntaxError,IndentationError,TabError) - Name & Scope (
NameError,UnboundLocalError,AttributeError) - Type & Value (
TypeError,ValueError,KeyError,IndexError,LookupError,AssertionError) - Arithmetic & Math (
ZeroDivisionError,OverflowError,FloatingPointError,SingularMatrixError) - File & Operating System (
FileNotFoundError,PermissionError,OSError,SubprocessError) - Import & Module (
ImportError,ModuleNotFoundError,ZipImportError) - Runtime & Recursion (
RuntimeError,RecursionError,NotImplementedError,ExceptionGroup) - Network & Connection (
ConnectionError,BrokenPipeError,TimeoutError,URLError) - Process & Lifecycle (
MemoryError,BufferError,KeyboardInterrupt,SystemExit) - Database & SQL (
DatabaseError,OperationalError,IntegrityError,ProgrammingError,SQLAlchemyError) - Web & HTTP APIs (
JSONDecodeError,HTTPError,RequestException,RateLimitError) - Data Science & Arrays (
EmptyDataError,ParserError,AxisError,LinAlgError,ShapeError) - Async & Concurrency (
CancelledError,InvalidStateError,QueueEmpty,ThreadError) - Security & Cryptography (
SSLError,AuthenticationError,ForbiddenError,JWTError) - Validation & Serialization (
ValidationError,PydanticCustomError,SchemaError) - Warnings & Deprecations (
DeprecationWarning,RuntimeWarning,UserWarning,FutureWarning)
License 📜
This project is licensed under the MIT License - see the LICENSE file for details.
Author & Contact 📞
- Author: Yahya Mundewadi
- Portfolio Website: yahya.in
- Project Portal: pydefine.yahya.in
- Email: yahyabuilds@gmail.com
- GitHub: @mdyahhya
- Instagram: @pydefine
✨ Powered by pyDefine ● Created by Yahya Mundewadi (yahya.in) ✨
Metadata
Release files for pydefine 1.1.27
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydefine-1.1.27.tar.gz | 38.9 kB | Without provenance | Details for pydefine-1.1.27.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydefine-1.1.27-py3-none-any.whl | Python 3 | none | any | Details for pydefine-1.1.27-py3-none-any.whl |
Total release size: 74.2 kB
Release files / pydefine-1.1.27.tar.gz
| Download URL | pydefine-1.1.27.tar.gz |
|---|---|
| Size | 38.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13051e4bd709f753de67ec8af16ffd2ad779cbfc94c521ae879ff5561c8aa1be
|
|
BLAKE2b-256 checksum How to use checksums |
7b3669ec3e72983fb17834e08768319f708c83e9f5c2608e3fd0d3e6de912e14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pydefine-1.1.27-py3-none-any.whl
| Download URL | pydefine-1.1.27-py3-none-any.whl |
|---|---|
| Size | 35.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7554fe9cdcfb5a64d0b149bfb7d9134395955d6195092011613aacc7a0975f43
|
|
BLAKE2b-256 checksum How to use checksums |
a0b301d09b4df0206b22e2a8c2b8c05104d39e797a4e69e68284273dee58b309
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for pydefine 1.1.27
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.