Skip to main content

Beginner-friendly Python error explainer

Project description

py-errorex

Beginner-friendly Python error explainer

py-errorex enhances Python error messages by providing clear explanations, reasons, and actionable fixes — helping beginners debug faster and understand their mistakes.


Features

  • Explains Python errors in simple language
  • Shows why the error happened
  • ️ Suggests practical fixes
  • Works instantly with any Python script
  • Focused on common beginner mistakes

Installation

Install from PyPI:

pip install py-errorex

Or install locally:

pip install .

Usage

Just enable ErrorX at the top of your script:

import py_errorex

py_errorex.enable()

data = None
print(len(data))

Default Python Error

TypeError: object of type 'NoneType' has no len()

With py-errorex

❌ TypeError: object of type 'NoneType' has no len()
👉 You are using something that is None

📍 File: app.py
🔢 Line: 4
👉 Code: print(len(data))

💡 Why:
The variable was never initialized or became None

👉 Fixes:
 - Initialize the variable before using it
 - Check if value is None
 - Use condition: if data is not None

Supported Errors

Currently supports:

  • TypeError (NoneType, incompatible types)
  • IndexError
  • KeyError
  • ZeroDivisionError
  • AttributeError
  • ValueError
  • FileNotFoundError

More patterns coming soon


How It Works

py-errorex hooks into Python’s global exception system:

sys.excepthook

When an error occurs:

  1. Captures traceback
  2. Identifies error type
  3. Matches known patterns
  4. Generates explanation + fixes
  5. Displays beginner-friendly output

Example

import py_errorex

py_errorex.enable()

arr = [1, 2, 3]
print(arr[5])

Output

❌ IndexError: list index out of range
👉 You are accessing an index that doesn't exist

💡 Why:
The index is greater than the list size

👉 Fixes:
 - Check list length using len(list)
 - Ensure index is within bounds
 - Use safe loops like: for item in list

Future Improvements

  • Colored terminal output
  • Smarter context-aware explanations
  • IDE / VS Code extension
  • More error patterns

Contributing

Contributions are welcome!

You can:

  • Add new error patterns
  • Improve explanations
  • Enhance formatting

License

MIT License


Support

If you found this useful, consider giving it a ⭐ on GitHub!


Made for learners, by a learner

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

py_errorex-0.1.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_errorex-0.1.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file py_errorex-0.1.3.tar.gz.

File metadata

  • Download URL: py_errorex-0.1.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for py_errorex-0.1.3.tar.gz
Algorithm Hash digest
SHA256 750746b8c8e03f90779556e5b6f274df828add7d9329ae454b48f218d05bc246
MD5 2ace821704b3cb3243422826214d291d
BLAKE2b-256 5e9ca60c20dfb24a759a715748b2c092e0bbdc764518d78d64b6a1ee81d2725f

See more details on using hashes here.

File details

Details for the file py_errorex-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: py_errorex-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for py_errorex-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2626cad01a50bd41fda455337376d3c73452353f90196b967859414bfed95353
MD5 a82d1f5ff53bff3f8453ec49e17eaf5c
BLAKE2b-256 c1234665d127eb589e3b340a4c8cb1644939333266f3e5bbbc2463ca5a5699a2

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