Print debugging works, but it’s slow. Breakpoints, step-through, profiling — professional tools for professional debugging.
breakpoint() — Built-in Debugger¶
def process_data(items): for item in items: result = transform(item) breakpoint() # Stops here — pdb prompt save(result)
Python Debugging — Techniques and Tools¶
VS Code Debugging¶
// .vscode/launch.json { “configurations”: [{ “name”: “Python: Current File”, “type”: “debugpy”, “request”: “launch”, “program”: “${file}”, “console”: “integratedTerminal” }] }
Profiling¶
cProfile¶
python -m cProfile -s cumulative myapp.py
line_profiler¶
@profile def slow_function(): …
kernprof -l -v myapp.py¶
Key Takeaway¶
breakpoint() for quick debugging, VS Code for step-through, cProfile for performance. Stop using print().