Set a breakpoint in code

Built-in breakpoint() works like import pdb; pdb.set_trace()

breakpoint() # Python 3.7+ — drops into pdb at this line

tool
python15 commands
tags
pythondebug

More python commands

  • pytest -x -v --tb=short tests/

    Stop at the first failure, with verbose output and short tracebacks

  • python3 -m py_compile script.py && echo OK

    Only compile to bytecode, to catch syntax errors

  • black --check --diff . && black .

    Show the diff first, then apply Black formatting

  • ruff check . --fix

    Fast linter with auto-fix that replaces flake8, isort and pyupgrade

  • mypy --strict --ignore-missing-imports src/

    Strict static type check for a package

all 15 python commands