官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 大港区| 泽州县| 浙江省| 雷州市| 英山县| 嘉善县| 甘南县| 阿鲁科尔沁旗| 梁平县| 安陆市| 通辽市| 西和县| 重庆市| 汨罗市| 高雄县| 弥渡县| 怀宁县| 区。| 郓城县| 镇巴县| 池州市| 特克斯县| 常德市| 会泽县| 曲松县| 阿鲁科尔沁旗| 南充市| 青铜峡市| 张家港市| 河北区| 泊头市| 磐安县| 山东省| 马尔康县| 康保县| 霸州市| 安康市| 汉沽区| 察雅县| 曲阜市| 明光市|