Friday, 15 August 2014

Can you step through python code to help debug issues? -


In java / c # you can easily move through the code, what is going wrong, and the IDE Makes the process very user-friendly.

Can you find out in a similar style through the python code?

Yes! To do this, there is a Python debugger called pdb !

You can use pdb via pdb myscript.py or python -m pdb myscript.py .

There are some commands that you can issue, which are documented on the page.

Some useful people have to remember:

  • b : set a breakpoint
  • c < / Code>:
  • s : step by step
  • n : do not hit until you have the next code To go to the line
  • L : List source code for the current file (default: 11 rows executing the line)
  • u : Navigate a stack frame to print the value of an expression in the current context
  • d : Navigate down a stack frame
  • p Li>

If you do not want to use a command line debugger, then some IDE such as a GUI debugger.


No comments:

Post a Comment