Saltar al contenido principal

Errors should explain the broken assumption

Handle a basic Python exception by naming the assumption that failed.

python-basics5 min read

The move: Expose the failed assumption A try-except block is not a blanket for uncertainty. It is a place to catch a specific failure, add context, and either recover or stop loudly. Broad silent catches create bad data with a clean terminal. PEP 8 frames style as a tool for readability, not decoration. The official tutorial teaches the same bias through examples: write the thing you mean, choose the built-in shape that matches the data, and keep the control flow visible. When a script moves from personal scratchpad to shared work, the cost of cleverness rises. Names, indentation, data shape,…

Read the full lesson

Sign up free: one personalized lesson every day, matched to your role and goals.

← Back to library

Contáctanos