A package to explain errors in Python code.
Project description
errorCoach
A friendly Python library that translates error messages into plain English explanations with helpful solutions.
What it does
When Python throws an error, it uses technical jargon that can be confusing for beginners. Error Coach intercepts these error messages and provides:
- Simple explanations of what went wrong
- Practical solutions to fix the problem
- Clean, readable formatting that's easy to understand
Installation (through pip)
pip install errorCoach
Quick Start
Just import and enable Error Coach at the top of your Python script:
from errorCoach import coach
coach.enable()
# Now your errors will be much more helpful!
x = 5 + "hello" # This will show a friendly explanation
Example
Before (standard Python error):
TypeError: unsupported operand type(s) for +: 'int' and 'str'
After (with Error Coach):
-------------------- Error-Coach --------------------
Error: TypeError: unsupported operand type(s) for +: 'int' and 'str'
What went wrong: You tried to add a number (int) and text (str).
How to Fix: Convert one using int() or str().
-----------------------------------------------------
Supported Error Types
Error Coach currently handles these common Python errors:
Type Errors
- Adding numbers and strings
- Calling non-callable objects
- String/number concatenation issues
Index Errors
- List index out of range
- String index out of range
Name Errors
- Undefined variables
- Typos in variable names
Key/Attribute Errors
- Missing dictionary keys
- Non-existent object attributes
Value Errors
- Invalid int() conversions
- Math domain errors
Syntax Errors
- Unclosed strings
- Missing colons/parentheses
- Indentation problems
Other Common Errors
- Division by zero
- File not found
- Missing modules
How it works
Error Coach uses Python's sys.excepthook to intercept exceptions before they're displayed. It matches error messages against a database of regex patterns and provides human-friendly explanations when matches are found.
For unrecognized errors, it falls back to Python's default error display.
Contributing
Found an error that should be explained better? Contributions are welcome! The error patterns and explanations are stored in the ERRORS dictionary - just add new patterns following the existing format.
License
MIT License - feel free to use this in your projects and educational materials.
Perfect for
- Learning Python - Get helpful explanations instead of cryptic errors
- Teaching Python - Help students understand what went wrong
- Debugging - Quickly identify common mistakes
- Code reviews - Better understand errors in others' code
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file errorcoach-0.0.1.tar.gz.
File metadata
- Download URL: errorcoach-0.0.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0c03095ba4a23ca037c82c3b8873f6d3920867f8945d444eb0a401121ffc599
|
|
| MD5 |
3851b4ccaeac99b85b16aefae55bd8b0
|
|
| BLAKE2b-256 |
c533a693a42b70c773988c2c5ea47a45689f0d249d2abc75906bc1837261a163
|
File details
Details for the file errorcoach-0.0.1-py3-none-any.whl.
File metadata
- Download URL: errorcoach-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a145704883fcfcbe254f2cab861665d6b900feb5ecea4997caa5d47caf3bd24c
|
|
| MD5 |
f8a146aa62ec4c04255b5ad52794330b
|
|
| BLAKE2b-256 |
3308261810b67a88fb634acb420db734ab002f18c99a2bbcda8b9202f00a5c68
|