Python's functional module [4], pdb/ipdb, enables single-step debugging of Python

Source: Internet
Author: User

pdb/ipdb modules /pdb/ipdb module

The main role of PDB and IPDB is for single-step debugging of Python programs, and Python debugging can refer to links.

Here is a simple example of using

1 Import ipdb   2   3 i = 0  4 while i<100:  5     Print  (i)  6    ipdb.set_trace ()  7     i + = 1  

Once you run the code, you can step through it, as long as you enter the instructions

Note:

1. Please try to avoid using Python's own idle operation, because the idle error will not find stdout,-.-| |.

2. pdb/ipdb debugging can use the Set_trace () function to set breakpoints, but it is worth noting that pdb/ipdb are difficult to support multi-threaded debugging, multi-threaded debugging can refer to the above link using pycharm.

The commands commonly used by the PDB are

     

Command

Explain

Break or b Set Breakpoints

Set breakpoints

Continue or C

Continue to execute the program

List or L

View the code snippet for the current row

Step or s

Enter function

return or R

Executes the code until it returns from the current function

Exit or Q

Abort and exit

Next or N

Executes the next line

Pp

Print the value of a variable

Help

Help

Reference Links

https://www.ibm.com/developerworks/cn/linux/l-cn-pythondebugger/

Python's functional module [4], pdb/ipdb, enables single-step debugging of Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.