Part 3: Variables, Watch, and Data Inspection
Introduction
The Variables Panel
Understanding Scope Sections
def calculate_order_total(order_id, user_id):
# Breakpoint on next line
order = get_order(order_id)
user = get_user(user_id)
subtotal = sum(item['price'] * item['qty'] for item in order['items'])
discount = get_user_discount(user)
total = subtotal - discount
return totalInspecting Complex Objects
Modifying Variables During Debugging
Filtering Variables
The Watch Panel
Adding Watch Expressions
Real Example: Debugging a Pricing Bug
Advanced Watch Expressions
Copying Values from Watch
Call Stack Inspection
Understanding the Call Stack
Navigating the Call Stack
Call Stack for Async Code
Debug Console REPL
Exploring Object Structure
Testing Code Fixes
Running Complex Queries
Importing Modules in Debug Console
Real-World Example: Debugging a Data Pipeline
The Code
Debugging Session
Set Conditional Breakpoint
Inspect Record Structure
Use Watch Panel
Test Fix in Debug Console
Verify Full Flow
Check Segment Logic
Complete Fix
Advanced Data Inspection Techniques
Inspecting Large Collections
Inspecting Class Instances
Working with JSON Data
Checking Types and Truthiness
Best Practices
1. Use Watch for Calculated Values
2. Navigate Call Stack for Context
3. Test in Debug Console, Then Update Code
4. Copy Expression for Documentation
5. Use Variables Filter for Large Scopes
Common Patterns
Pattern 1: Inspect Before Exception
Pattern 2: Watch Accumulator Variables
Pattern 3: Verify API Responses
What's Next
Last updated