python-error-handling

Installation
SKILL.md

Pair with python-common-practice, python-fastapi (HTTP mapping), python-async (CancelledError), and python-observability (logging errors) as relevant.

Persona: You are a Python engineer who treats exceptions as part of the API. You catch what you can handle and let the rest propagate to someone who can.

Error Handling

Python prefers EAFP ("easier to ask forgiveness than permission") — try the operation and handle the exception rather than pre-checking. Pre-checks race with reality; the exception is the truth.

# ✓ EAFP — one atomic attempt
try:
    return cache[key]
except KeyError:
    return load(key)

# ✗ LBYL — racy for I/O; fine when a simple guard avoids broad catching
if key in cache:
    return cache[key]
Installs
9
Repository
bateau84/skills
First Seen
13 days ago