Usage

import ipdb
 
def add(a, b):
    result = a + b
    ipdb.set_trace()  # This sets a breakpoint
    return result
 
print(add(3, 4))

Common Commands

Here are some common ipdb commands you can use during a debugging session:

  • n (next): Move to the next line within the same function.
  • s (step): Step into the function being called.
  • c (continue): Continue execution until the next breakpoint.
  • q (quit): Exit the debugger.
  • p (print): Print the value of an expression.
p variable_name
  • l (list): Show the current location in the code.
  • u (up): Move up in the stack trace.
  • d (down): Move down in the stack trace.