Python Debugging using PDB


Python Debugging

PDB is a library that allows you to extract Python scripts. This article will discuss how to use it in a very simple way.
We can run a Python script from the command line to debug.

How to use Python PDB

When executed this way, the script debug process will start from the beginning of the code.
Here, we can start our debug process. Of course, we started the Debug process from the first line with this process. This is not the case. For this reason, we can write the following code on any line in the script.

We will interpret our program until we write this code, and after that, it will drop us to the Pdb shell. Now we do the simple code that we wrote, and then we run it from the command line normally without using the – pdb.

the program was interpreted normally until it came to the PDB line and dropped us to the PDB shell after it came to the line. That’s all we need to do to debug. Now, let’s see what we can do after we fall into the PDB shell.

Python Debugging Commands

  1. l(ist) : Allows us to list the code we have written.
  2. w(here) : Writes the line where the program is.
  3. c(ontinue : Allows the program to continue to interpret where it left off.
  4. b(reak) SatirNumarasi : Break point to the line number.
  5. tbreak SatirNumarasi : Temporarily puts break point. After the first transaction, break point is deleted.
  6. q(uit) : Exits debug.
  7. c(lear) : Used to clean break points. If y(es) answer is given to the question, break points are deleted.
  8. commands BreakPointNumarasi : Enters the break point number to run the desired commands. Its use is as follows. The end statement is used to exit command.
  9. s(tep) : Move to the next row.
  10. n(ext) : Move to the next row.
  11. j(ump) SatirNumarasi :Jumps to the typed line number.
  12. a(rgs) :Returns the arguments of the default function.
  13. p a :a prints the value of the variable to the screen.
  14. run : Reboot the Debug program. продажа купажная емкость.