What's the use of Python PDB?
This article is to share with you about the usefulness of Python PDB. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
What is Python PDB?
According to the definition of PDB in the Python document, it is a module that provides an interactive source code debugging function for Python programs. The main features (feature) include:
Conditional breakpoint
Single-step debugging of source code at line level
View stack fragments
Evaluate arbitrary code in the context of arbitrary stack fragments (similar to GDB)
Code list
Other
Use Python PDB for simple debugging
The Python program can also achieve a single-step debugging function similar to cAccord +, while the debug module PDB in Python is similar to GDB (common commands, etc.) in c, which can be debugged conveniently.
Here is an example (debug_demo.py):
#! / usr/bin/env Python _ debug = True def debug_demo (val): if _ debug: import pdb pdb.set_trace () # introduce the related pdb module if val
< 10: print "less than 10" elif val /home/tower/test/Python/debug.py(9)debug_demo() ->If val