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

Within an interpreter

 To start the debugger from the Python interactive console, we are using run() or runeval().

Start your python3 interactive console. Run the following command to start the console:

 $ python3

Import our pdb_example script name and the pdb module. Now, we are going to use run() and we are passing a string expression as an argument to run() that will be evaluated by the Python interpreter itself:

student@ubuntu:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import pdb_example
>>> import pdb
>>> pdb.run('pdb_example.Student(5).print_std()')
> <string>(1)<module>()
(Pdb)

To continue debugging, enter continue after the (Pdb) prompt and press Enter. If you want to know the options we can use in this, then after the (Pdb) prompt press the Tab key twice.

Now, after entering continue, we will get the output as follows:

student@ubuntu:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import pdb_example
>>> import pdb
>>> pdb.run('pdb_example.Student(5).print_std()')
> <string>(1)<module>()
(Pdb) continue
0
1
2
3
4
>>>
主站蜘蛛池模板: 谢通门县| 元阳县| 嘉鱼县| 乡宁县| 江门市| 宁阳县| 南投市| 郑州市| 新蔡县| 洪雅县| 临汾市| 石城县| 宜章县| 安龙县| 澄城县| 罗江县| 佛学| 绥德县| 嘉鱼县| 佳木斯市| 奉化市| 舟山市| 新绛县| 阿拉善右旗| 上饶市| 扬州市| 龙江县| 扶风县| 金堂县| 荣成市| 鄂尔多斯市| 碌曲县| 江津市| 洛阳市| 日喀则市| 丰宁| 芦溪县| 屯门区| 密山市| 文安县| 靖安县|