PDB Common Commands

Source: Internet
Author: User

The remote debugging Python program primarily uses logging and PDB for debugging. On the one hand there is no permission to install IPDB, on the other hand it cannot be debugged locally.

How to use

The PDB is a module that comes with Python, so no additional installation is required. If you need more advanced debugging, you can try IPDB. Insert a breakpoint where you want to debug:

import pdb;pdb.set_trace()

Note that breakpoints are blocking, so be sure to remove breakpoints before you go live. So from this point of view the print log is more convenient than setting breakpoints.

If the number of lines of code is small, and the way to start the program is simple, you can also use the following command debugging, eliminating the addition of breakpoints and delete breakpoints.

python -m pdb ouyangsong.py
Common commands


Calculates and prints the values of variables, and print similar. You can also enter the variable name directly and the value of the variable will be printed.


The next line can be used when debugging by line.


Continue running until the next breakpoint, which is the abbreviation for continue.


Look at the code near the breakpoint to make it easy to know where you are.


Add a line number in the back, and you'll be adding breakpoints dynamically.


Go inside the function.


Executes the code until it is returned from the current function.


Force exit so the program exits unexpectedly.


is actually executing any code. such as forcing a change to test different examples.


PDB Common Commands

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.