How do you watch a variable in pdb
问题 I'm debugging a python script, and I want to watch a variable for a change (much like you can watch a memory adress in gdb). Is there a way to do this? 回答1: For watching a variable when you are hitting a breakpoint , you can use the commands command. E.g. printing some_variable when hitting breakpoint #1 (canonical example from pdb doc). (Pdb) commands 1 (com) print some_variable (com) end (Pdb) Update for Python 3 (Pdb) commands 1 (com) print(some_variable) (com) end (Pdb) Additionally, you