我想修改Python 3.4内置调试器的源代码pdb
(我假设它是用Python编写的)。我想添加一些代码,以便在我放入时:
pdb.set_trace(locals())
在我的代码中,它调用控制台中的标准pdb
接口,并自动显示有关我的本地环境变量的格式化信息,类似于下表。
有人能指出我pdb
的源代码吗?
-------------------- Objects: -----------------------------------[2000]
[Name: dog] [Data type: "Dog"] [2100]
+------+-------+-------+-------+------------+------------+
| ID | breed | color | name | size | uuid |
+------+-------+-------+-------+------------+------------+
| 2110 | lynx | black | dog-3 | large!!!!! | e30475ad-9 |
+------+-------+-------+-------+------------+------------+
[Name: cat] [Data type: "Cat"] [2200]
+------+-------+-------+---------+------------+
| ID | breed | color | name | size |
+------+-------+-------+---------+------------+
| 2210 | lynx | black | kitty-5 | large!!!!! |
+------+-------+-------+---------+------------+
-------------------- Lists of Objects: --------------------------[3000]
[Name: cats] [Data type: "list"] [3100]
+------+-------+-------+---------+------------+
| ID | breed | color | name | size |
+------+-------+-------+---------+------------+
| 3110 | lynx | black | kitty-1 | large!!!!! |
| 3120 | lynx | black | kitty-2 | large!!!!! |
| 3130 | lynx | black | kitty-3 | large!!!!! |
| 3140 | lynx | black | kitty-4 | large!!!!! |
| 3150 | lynx | black | kitty-5 | large!!!!! |
+------+-------+-------+---------+------------+
[Name: dogs] [Data type: "list"] [3200]
+------+-------+-------+-------+------------+------------+
| ID | breed | color | name | size | uuid |
+------+-------+-------+-------+------------+------------+
| 3210 | lynx | black | dog-1 | large!!!!! | e30475ad-9 |
| 3220 | lynx | black | dog-2 | large!!!!! | e30475ad-9 |
| 3230 | lynx | black | dog-3 | large!!!!! | e30475ad-9 |
+------+-------+-------+-------+------------+------------+
答案 0 :(得分:1)
pdb
只是一个普通的模块,作为标准库的一部分提供。因此,您只需查看本地lib
文件夹即可找到pdb.py
来源。
当然,您也可以在线查看,例如在Python source repository。