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

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
>>>
主站蜘蛛池模板: 佛山市| 商城县| 兴安县| 宜兰市| 门源| 南投市| 淳化县| 宁乡县| 罗山县| 高碑店市| 侯马市| 许昌县| 长兴县| 巩留县| 资兴市| 搜索| 萨嘎县| 博湖县| 松阳县| 治多县| 东阳市| 永顺县| 吉木乃县| 沂水县| 文安县| 博兴县| 安徽省| 曲阜市| 贵德县| 高碑店市| 栾川县| 禹城市| 修武县| 赣榆县| 化德县| 乌鲁木齐县| 昌黎县| 阜平县| 台南市| 罗田县| 淮阳县|