Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In pdb how do you reset the list (l) command line count?

Tags:

python

pdb

From PDB

(Pdb) help l
l(ist) [first [,last]]
  List source code for the current file.
  Without arguments, list 11 lines around the current line
  or continue the previous listing.
  With one argument, list 11 lines starting at that line.
  With two arguments, list the given range;
  if the second argument is less than the first, it is a count.

The "continue the previous listing" feature is really nice, but how do you turn it off?

like image 355
Jorge Vargas Avatar asked Aug 23 '09 14:08

Jorge Vargas


People also ask

What are these Pdb commands used for?

Essential pdb CommandsPrint the value of an expression. Pretty-print the value of an expression. Continue execution until the next line in the current function is reached or it returns. Execute the current line and stop at the first possible occasion (either in a function that is called or in the current function).

How do I clear the Pdb screen?

Then when you are in Pdb, you can type cls() to clear the screen without needing as many key strokes at the command line.

What does Pdb set Trace do?

The debugger has a trace function that it uses to track the execution of your code. It examines the current stack frame to see if you've gotten to a breakpoint, for example. pdb. set_trace means, "set the pdb trace function as the trace function with sys.

How do I get out of Pdb in Python?

from pdb, just type disable N, where N is the breakpoint number you are stuck on. If you don't know the number of your troubling breakpoint, enter tbreak. This will list your breakpoints by number under column "Num" and show whether (yes) or not (no) they are enabled or disabled under the column headed with "Enb."


2 Answers

Late but hopefully still helpful. In pdb, make the following alias (which you can add to your .pdbrc file so it's always available):

alias ll u;;d;;l 

Then whenever you type ll, pdb will list from the current position. It works by going up the stack and then down the stack, which resets 'l' to show from the current position. (This won't work if you are at the top of the stack trace.)

like image 91
Ghopper21 Avatar answered Sep 28 '22 18:09

Ghopper21


Try this.

(pdb) l .

Maybe you can always type the dot.

ps. You may consider to use pudb. This is a nice UI to pdb what gdbtui is to gdb.

like image 34
plhn Avatar answered Sep 28 '22 16:09

plhn