5

I would like to know how to use the debug command in pdb?

(Pdb) help

Documented commands (type help <topic>):
========================================
EOF    c          d        h         list      q        rv       undisplay
a      cl         debug    help      ll        quit     s        unt
alias  clear      disable  ignore    longlist  r        source   until
args   commands   display  interact  n         restart  step     up
b      condition  down     j         next      return   tbreak   w
break  cont       enable   jump      p         retval   u        whatis
bt     continue   exit     l         pp        run      unalias  where

Miscellaneous help topics:
==========================
pdb  exec
(Pdb) help debug
debug code
        Enter a recursive debugger that steps through the code
        argument (which is an arbitrary expression or statement to be
        executed in the current environment).
(Pdb) debug print('hello')
ENTERING RECURSIVE DEBUGGER
> <string>(1)<module>()->None
((Pdb)) n
hello
--Return--
> <string>(1)<module>()->None
((Pdb)) n
LEAVING RECURSIVE DEBUGGER
(Pdb)

2 Answers 2

3

The question confused me years. I always forgot to search the final answer. But today I get it, and share what I find here.

How can I debug manually typed expression and statements in pdb?

When you are in the recursive debug mode first time, type s , you will kwon what to do the next.

Sign up to request clarification or add additional context in comments.

1 Comment

Finally I understand the purpose and how to use this option! Thanks!
-1

Let, you have a bunch of code. You put pdb, say line 3.

In this case, when you run the program, line 1 and line 2 is executed automatically and you can see the result by putting the variable name and from line 4 is not executed.

If you wanna see after line 3 result you have to write code which results you want to see or you can go next line using n, and c for continuing that means exit from debugging mode.

1 Comment

Thanks @Shaon but I do understand how to debug with Python but there is one command debug (see help command) that I don't understand. Do you have an example of how to use the debug command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.