Part 2: Breakpoints and Stepping Through Code
Introduction
Breakpoint Types
Regular Breakpoints - What You Know
def process_payment(amount, user_id):
balance = get_balance(user_id) # β Red dot = always pauses here
if balance >= amount:
deduct(user_id, amount)
return True
return FalseConditional Breakpoints - Game Changer
Expression Condition
Hit Count Condition
Triggered Breakpoints
Logpoints - Debug Without Stopping
Inline Breakpoints
Function Breakpoints
Data Breakpoints (Python Limited Support)
Stepping Through Code
Step Over (F10)
Step Into (F11)
Step Out (Shift+F11)
Continue (F5)
Restart (Shift+Cmd+F5)
Stop (Shift+F5)
Real-World Example: Debugging an API Data Transformation
The Code
Debugging Strategy
Step 1: Conditional Breakpoint
Step 2: Start Debugging
Step 3: Inspect Variables
Step 4: Test Fix in Debug Console
Step 5: Update Code
Advanced Stepping Techniques
Smart Stepping
Run to Cursor
Jump to Cursor (Set Next Statement)
Debugging Loops Efficiently
Problem: Inspecting Loop Iterations
Real Example: Finding Bad Data
Exception Breakpoints
Enable in VS Code
Uncaught Exceptions Only
Keyboard Shortcuts Mastery
Action
Shortcut
When to Use
Best Practices
1. Use Conditional Breakpoints for Loops
2. Logpoints for High-Frequency Code
3. Step Over Trusted Functions
4. Use Run to Cursor for Quick Navigation
What's Next
PreviousPart 1: Getting Started with Debugging in VS CodeNextPart 3: Variables, Watch, and Data Inspection
Last updated