- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 128字
- 2021-07-02 14:00:32
The pdb debugger
The pdb module is used to debug Python programs. Python programs use pdb interactive source code debugger to debug the programs. pdb sets breakpoints and inspects the stack frames, and lists the source code.
Now we will learn about how we can use the pdb debugger. There are three ways to use this debugger:
- Within an interpreter
- From a command line
- Within a Python script
We are going to create a pdb_example.py script and add the following content in that script:
class Student:
def __init__(self, std):
self.count = std
def print_std(self):
for i in range(self.count):
print(i)
return
if __name__ == '__main__':
Student(5).print_std()
Using this script as an example to learn Python debugging, we will see how we can start the debugger in detail.
推薦閱讀
- 微服務(wù)與事件驅(qū)動(dòng)架構(gòu)
- 教孩子學(xué)編程:C++入門圖解
- Kali Linux Wireless Penetration Testing Beginner's Guide(Third Edition)
- 軟件測試技術(shù)指南
- Java系統(tǒng)化項(xiàng)目開發(fā)教程
- Android玩家必備
- Learning Unreal Engine Android Game Development
- ActionScript 3.0從入門到精通(視頻實(shí)戰(zhàn)版)
- 深入淺出Python數(shù)據(jù)分析
- Visual Basic程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)及考試指南
- 安卓工程師教你玩轉(zhuǎn)Android
- MySQL從入門到精通
- Java程序設(shè)計(jì)基礎(chǔ)教程
- Microsoft Azure Security
- Flask Web開發(fā)實(shí)戰(zhàn):入門、進(jìn)階與原理解析