jbl
jbl

Reputation: 582

python3 pdb: how to repeat multiple commands

How do you repeat a multiple commands?

Multiple commands may be entered on a single line, separated by ;;.
[...]
Entering a blank line repeats the last command entered.

I have already tried:

n ;; l
<ENTER>

But only the list command would be repeated.

Sticking with pdb (no ipdb & co), would you know how to repeat effortlessly multiple commands?

Thanks !

Upvotes: 4

Views: 1318

Answers (2)

Song Wukong
Song Wukong

Reputation: 43

Well, the documentation https://docs.python.org/3/library/pdb.html says

Exception: if the last command was a list command, the next 11 lines are listed.

just right after

Entering a blank line repeats the last command entered

you've mentioned

In your expression

n;;l

as we can see the list command 'l' appears to be the last given command which directly hits the exception

I've faced the same problem and found some sort of a solution - we can simply repeat the last command n;;l by pressing up-arrow key and then enter, just like in terminal. Hope this helps.

Upvotes: 2

Lorem Ipsum
Lorem Ipsum

Reputation: 4534

As indicated by @Song, the reason you can't repeat the desired behavior, i.e. stepping rather than showing context, is because the last command in n ;; l is l.

The way I get around this is to use caps for my aliases. Here is what my .pdbrc file looks like:

# Enable completion
import pdb
import rlcompleter
pdb.Pdb.complete=rlcompleter.Completer(locals()).complete

# Show context on startup
l

alias S 'Stepping into...' ;; step ;; l
alias N 'Stepping over...' ;; next ;; l
alias C 'Continuing...' ;; continue ;; l
alias R 'Going to return...' ;; return ;; l

The preceding strings "Stepping into...", etc. let you know when you're executing a custom command versus a native pdb command.

These same commands work for ipdb, too.

Upvotes: 3

Related Questions