Basic Python debugging in Linux

Source: Internet
Author: User

When there is no ide at hand and you are worried about Python debugging, you can refer to this article. (PDB command debugging)
Reference: http://docs.python.org/library/pdb.html
And (PDB) Help

First you choose to run the py
Python-m pdb myscript. py

(PDB) will automatically stop at the first line, waiting for debugging, then you can look at the help
(PDB) h
Describe these key commands

> Breakpoint settings
(PDB) B 10 # Set the breakpoint to the 10th rows of this py
Or (PDB) B ots. py: 20 # Set the breakpoint to ots. py row 20th
Delete breakpoint (PDB) B # view the breakpoint number
(PDB) Cl 2 # Delete 2nd breakpoints

> RUN
(PDB) N # single-step operation
(PDB) s # click it to run, that is, click Next, AND THE METHOD
(PDB) C # jump to the next breakpoint
> View
(PDB) P Param # view the current variable value
(PDB) L # view the code running somewhere
(PDB) A # view all intra-stack variables

> If the debugging is in the command line:

Import PDB
Def TT ():
PDB. set_trace ()
For I in range (1, 5 ):
Print I

>>> TT ()
# N p c is supported here
> (3) TT ()
(PDB) N

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.