Skip to the workspace
Pebellslearn by building

Python syntax & reference

Find the form you need, compare how it behaves, and open the complete explanation when you need more depth.

Python 3.10+ syntax; individual entries identify newer features. Browser exercises use the configured Python runner.

1 matching syntax entry

Raising with context

Learn in depth →

raise from connects an application error to the lower-level failure that caused it.

raise DomainError("message") from error

Example

try:
    try:
        int("bad")
    except ValueError as error:
        raise RuntimeError("invalid record") from error
except RuntimeError as error:
    print(type(error.__cause__).__name__)

Result

ValueError

Watch for: Do not swallow failures or expose secrets in messages. Preserve enough context for diagnosis.

Practise this topic →
Complete explanation index (91 lessons indexed)

The Hierarchy, `raise from` & `finally`

Technical sources and review date

Original Pebells examples. Reviewed 2026-10-28.

Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.