Introduction to the Python debugger (PDB)

Source: Internet
Author: User
Tags pprint

Transferred from: http://www.cnblogs.com/wei-li/archive/2012/05/02/2479082.html

Learn python debugging, the best information is of course official documents and (PDB) help, here is a blog post, and the following PDB Cheat-sheet

1 using the PDB module in Python can be debugged
Import PDB
Pdb.set_trace ()


2 You can also use the python-m PDB mysqcript.py in such a way that the (PDB) will automatically stop at the first line and wait for debugging; You can see the Help (PDB) H (ELP)
Explain these key commands
> Breakpoint Settings
(Pdb) B #断点设置在本py的第10行
or (Pdb) b ots.py:20 #断点设置到 ots.py line 20th
Delete Breakpoint (Pdb) b #查看断点编号
(PDB) CL 2 #删除第2个断点
> Operation
(PDB) n #单步运行
(PDB) s #细点运行 that's going down, method
(PDB) C #跳到下个断点
> View
(Pdb) p param #查看当前 Variable value
(PDB) L #查看运行到某处代码
(PDB) A #查看全部栈内变量
(PDB) W lists the layers in the current call stack.
(Pdb) d moves down one layer in the call stack
(Pdb) u move up one layer in the call stack. If you press n after a layer has been moved up, the next narrative will be performed at the level after the move up, and the previous function call will automatically return.
(PDB) CL clears the specified breakpoint. If no parameters are taken, all breakpoints are cleared.
(Pdb) Disable the ability to cancel all breakpoints, but still retain those breakpoints.
(PDB) enable the ability to restore breakpoints.
(PDB) Ignore sets the number of times the breakpoint is ignored. If count is not specified, it is initially 0. When Count is 0 o'clock, the breakpoint will act normally. If count is specified, the count is less than 1, until the count is 0, each time the interrupt is performed.
(Pdb) condition Bpnumber [condition]
(PDB) J (UMP) Lineno. Jumps to a row to execute. It only works at the bottom of the call stack.
(PDB) L lists the location in the current file. The continuous l command is always listed at the end of the file and can be printed using the specified number of rows or ranges.
(Pdb) the PP and P commands are similar, but using the Pprint module (Pprint is not used, please refer to Python Library Reference for details).
(PDB) alias takes an "alias" instead of "a bunch of debug commands," Something like C/S macro (see Python Library Reference for details).
(PDB) Unalias cancels an alias.
(PDB) [!] Statement the narrative in the current environment (context).

Introduction to the Python debugger (PDB)

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.