Skip to content

Lesson 23 · Python

Professional Practice Capstone — Debug, Profile & Ship

The module capstone: read tracebacks bottom-up, corner bugs with breakpoint() and pdb, profile with cProfile and pstats, then ship a complete temperature-converter CLI - tests green, ruff clean, packaged and documented.

60 minintermediateProfessional Practice

Prerequisites: Professional Practice: Type Hints, Linting & Docs

Learning objectives
By the end of this lesson, you will be able to:
  • Read any Python traceback bottom-up: exception first, innermost frame second, your own code before the stdlib's
  • Stop a program mid-run with breakpoint() and inspect it with the five pdb commands you will use daily: l, n, s, p and c
  • Profile code with cProfile and pstats, and interpret tottime versus cumulative time without fooling yourself
  • Choose honestly between print-debugging and the debugger based on the bug and the cost of re-running
  • Ship a small project the professional way: venv, pyproject.toml, green pytest suite, ruff-clean code and a README a stranger can follow