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

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.

主站蜘蛛池模板: 香河县| 长宁区| 信丰县| 临洮县| 香河县| 康平县| 武义县| 宝山区| 弋阳县| 山东省| 芷江| 两当县| 湛江市| 桐柏县| 三门县| 河北区| 临潭县| 武胜县| 宁海县| 嘉峪关市| 凯里市| 浦江县| 北海市| 岑溪市| 图木舒克市| 新乐市| 梅州市| 房产| 徐闻县| 大荔县| 长岭县| 团风县| 拜城县| 固始县| 嵊泗县| 绥芬河市| 南木林县| 望奎县| 马边| 岢岚县| 赤城县|